diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / tensorflow / contrib / metrics / BUILD <nl> ppp b / tensorflow / contrib / metrics / BUILD <nl> py_test ( <nl> " / / third_party / py / numpy " , <nl> ] , <nl> ) <nl> + <nl> + py_test ( <nl> + name = " metric_ops_large_test " , <nl> + size = " large " , <nl> + srcs = [ " python / ops / metric_ops_large_test . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + tags = [ " noasan " ] , # times out b / 63678675 <nl> + deps = [ <nl> + " : metrics_py " , <nl> + " / / tensorflow / python : array_ops " , <nl> + " / / tensorflow / python : client_testlib " , <nl> + " / / tensorflow / python : data_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 : random_ops " , <nl> + " / / tensorflow / python : sparse_tensor " , <nl> + " / / tensorflow / python : variables " , <nl> + " / / third_party / py / numpy " , <nl> + ] , <nl> + ) <nl> new file mode 100644 <nl> index 0000000000000 . . 7acfc383eb9a6 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / metrics / python / ops / metric_ops_large_test . py <nl> <nl> + # Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Large tests for metric_ops . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import numpy as np <nl> + from six . moves import xrange # pylint : disable = redefined - builtin <nl> + from tensorflow . contrib . metrics . python . ops import metric_ops <nl> + from tensorflow . python . framework import dtypes as dtypes_lib <nl> + from tensorflow . python . framework import ops <nl> + from tensorflow . python . ops import math_ops <nl> + from tensorflow . python . ops import random_ops <nl> + from tensorflow . python . ops import variables <nl> + from tensorflow . python . platform import test <nl> + <nl> + <nl> + class StreamingPrecisionRecallAtEqualThresholdsLargeTest ( test . TestCase ) : <nl> + <nl> + def setUp ( self ) : <nl> + np . random . seed ( 1 ) <nl> + ops . reset_default_graph ( ) <nl> + <nl> + def testLargeCase ( self ) : <nl> + shape = [ 32 , 512 , 256 , 1 ] <nl> + predictions = random_ops . random_uniform ( <nl> + shape , 0 . 0 , 1 . 0 , dtype = dtypes_lib . float32 ) <nl> + labels = math_ops . greater ( random_ops . random_uniform ( shape , 0 . 0 , 1 . 0 ) , 0 . 5 ) <nl> + <nl> + result , update_op = metric_ops . precision_recall_at_equal_thresholds ( <nl> + labels = labels , predictions = predictions , num_thresholds = 201 ) <nl> + # Run many updates , enough to cause highly inaccurate values if the <nl> + # code used float32 for accumulation . <nl> + num_updates = 71 <nl> + <nl> + with self . test_session ( ) as sess : <nl> + sess . run ( variables . local_variables_initializer ( ) ) <nl> + for _ in xrange ( num_updates ) : <nl> + sess . run ( update_op ) <nl> + <nl> + prdata = sess . run ( result ) <nl> + <nl> + # Since we use random values , we won ' t know the tp / fp / tn / fn values , but <nl> + # tp and fp at threshold 0 should be the total number of positive and <nl> + # negative labels , hence their sum should be total number of pixels . <nl> + expected_value = 1 . 0 * np . product ( shape ) * num_updates <nl> + got_value = prdata . tp [ 0 ] + prdata . fp [ 0 ] <nl> + # They should be at least within 1 . <nl> + self . assertNear ( got_value , expected_value , 1 . 0 ) <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + test . main ( ) <nl> mmm a / tensorflow / contrib / metrics / python / ops / metric_ops_test . py <nl> ppp b / tensorflow / contrib / metrics / python / ops / metric_ops_test . py <nl> def testValuesAreIdempotent ( self ) : <nl> for _ in range ( 3 ) : <nl> self . _testResultsEqual ( initial_result , result ) <nl> <nl> - def testLargeCase ( self ) : <nl> - self . skipTest ( " Test consistently timing out " ) <nl> - shape = [ 32 , 512 , 256 , 1 ] <nl> - predictions = random_ops . random_uniform ( <nl> - shape , 0 . 0 , 1 . 0 , dtype = dtypes_lib . float32 ) <nl> - labels = math_ops . greater ( random_ops . random_uniform ( shape , 0 . 0 , 1 . 0 ) , 0 . 5 ) <nl> - <nl> - result , update_op = metric_ops . precision_recall_at_equal_thresholds ( <nl> - labels = labels , predictions = predictions , num_thresholds = 201 ) <nl> - # Run many updates , enough to cause highly inaccurate values if the <nl> - # code used float32 for accumulation . <nl> - num_updates = 71 <nl> - <nl> - with self . test_session ( ) as sess : <nl> - sess . run ( variables . local_variables_initializer ( ) ) <nl> - for _ in xrange ( num_updates ) : <nl> - sess . run ( update_op ) <nl> - <nl> - prdata = sess . run ( result ) <nl> - <nl> - # Since we use random values , we won ' t know the tp / fp / tn / fn values , but <nl> - # tp and fp at threshold 0 should be the total number of positive and <nl> - # negative labels , hence their sum should be total number of pixels . <nl> - expected_value = 1 . 0 * np . product ( shape ) * num_updates <nl> - got_value = prdata . tp [ 0 ] + prdata . fp [ 0 ] <nl> - # They should be at least within 1 . <nl> - self . assertNear ( got_value , expected_value , 1 . 0 ) <nl> - <nl> def _testCase ( self , <nl> predictions , <nl> labels , <nl> | Splits testLargeCase in metric_ops_test into a dedicated file for slow - running tests and re - enables it as a ' large ' test . | tensorflow/tensorflow | 4254b2ca729858d5bff2bbd570b4f7b02d42fd35 | 2018-06-13T20:13:31Z |
mmm a / tools / buildsteps / windows / patches / 0001 - ffmpeg - detect - openssl . patch <nl> ppp b / tools / buildsteps / windows / patches / 0001 - ffmpeg - detect - openssl . patch <nl> mmm a / configure <nl> ppp b / configure <nl> - enabled openssl & & { use_pkg_config openssl openssl / ssl . h OPENSSL_init <nl> - check_lib openssl / ssl . h SSL_library_init - lssl - lcrypto | | <nl> - check_lib openssl / ssl . h SSL_library_init - lssl32 - leay32 | | <nl> - check_lib openssl / ssl . h SSL_library_init - lssl - lcrypto - lws2_32 - lgdi32 | | <nl> - + check_lib openssl / ssl . h SSL_library_init - llibeay32 - lssleay32 | | <nl> + <nl> + check_lib openssl openssl / ssl . h SSL_library_init - lssl - lcrypto | | <nl> + check_lib openssl openssl / ssl . h SSL_library_init - lssl32 - leay32 | | <nl> + check_lib openssl openssl / ssl . h SSL_library_init - lssl - lcrypto - lws2_32 - lgdi32 | | <nl> + + check_lib openssl openssl / ssl . h SSL_library_init - llibeay32 - lssleay32 | | <nl> die " ERROR : openssl not found " ; } <nl> - enabled qtkit_indev & & { check_header_objcc QTKit / QTKit . h | | disable qtkit_indev ; } <nl> - <nl> + enabled rkmpp & & { { require_pkg_config rockchip_mpp rockchip_mpp rockchip / rk_mpi . h mpp_create | | <nl> + die " ERROR : Rockchip MPP was not found . " ; } & & <nl> - - <nl> 2 . 10 . 1 . windows . 1 <nl> <nl> mmm a / tools / buildsteps / windows / patches / 0002 - ffmpeg - zlib - config - conflict . patch <nl> ppp b / tools / buildsteps / windows / patches / 0002 - ffmpeg - zlib - config - conflict . patch <nl> <nl> mmm a / configure <nl> ppp b / configure <nl> - <nl> + <nl> $ CONFIG_EXTRA \ <nl> $ ALL_COMPONENTS \ <nl> <nl> <nl> + echo " # undef HAVE_UNISTD_H " > > $ TMPH <nl> + echo " # endif " > > $ TMPH <nl> echo " # endif / * FFMPEG_CONFIG_H * / " > > $ TMPH <nl> - echo " endif # FFMPEG_CONFIG_MAK " > > config . mak <nl> + echo " endif # FFMPEG_CONFIG_MAK " > > ffbuild / config . mak <nl> <nl> mmm a / tools / depends / target / ffmpeg / CMakeLists . txt <nl> ppp b / tools / depends / target / ffmpeg / CMakeLists . txt <nl> elseif ( CORE_SYSTEM_NAME STREQUAL android ) <nl> else ( ) <nl> list ( APPEND ffmpeg_conf - - cpu = i686 - - disable - mmx ) <nl> endif ( ) <nl> - list ( APPEND ffmpeg_conf - - target - os = linux - - extra - libs = - liconv ) <nl> + list ( APPEND ffmpeg_conf - - target - os = linux - - extra - libs = - liconv - - disable - linux - perf ) <nl> elseif ( CORE_SYSTEM_NAME STREQUAL ios ) <nl> if ( NOT CPU MATCHES arm64 ) <nl> list ( APPEND ffmpeg_conf - - cpu = cortex - a8 ) <nl> elseif ( CORE_SYSTEM_NAME STREQUAL ios ) <nl> list ( APPEND ffmpeg_conf - - disable - decoder = mpeg_xvmc - - disable - vda - - disable - crystalhd - - enable - videotoolbox <nl> - - target - os = darwin ) <nl> elseif ( CORE_SYSTEM_NAME STREQUAL osx ) <nl> - list ( APPEND ffmpeg_conf - - disable - outdev = sdl <nl> - - - disable - decoder = mpeg_xvmc - - disable - vda - - disable - crystalhd - - enable - videotoolbox <nl> + list ( APPEND ffmpeg_conf - - disable - decoder = mpeg_xvmc - - disable - vda - - disable - crystalhd - - enable - videotoolbox <nl> - - target - os = darwin <nl> - - disable - securetransport ) <nl> endif ( ) <nl> externalproject_add ( ffmpeg <nl> - - disable - ffmpeg <nl> - - disable - ffprobe <nl> - - disable - ffserver <nl> - - - disable - sdl <nl> - - enable - gpl <nl> - - enable - runtime - cpudetect <nl> - - enable - postproc <nl> mmm a / tools / depends / target / ffmpeg / FFMPEG - VERSION <nl> ppp b / tools / depends / target / ffmpeg / FFMPEG - VERSION <nl> <nl> LIBNAME = ffmpeg <nl> BASE_URL = https : / / github . com / xbmc / FFmpeg <nl> - VERSION = 3 . 3 . 4 - Leia - Alpha - 1 <nl> + VERSION = 3 . 4 - Leia - Alpha - 1 <nl> ARCHIVE = $ ( LIBNAME ) - $ ( VERSION ) . tar . gz <nl> GNUTLS_VER = 3 . 4 . 14 <nl> mmm a / tools / depends / target / ffmpeg / Makefile <nl> ppp b / tools / depends / target / ffmpeg / Makefile <nl> APPLY_PATCHES = no <nl> ffmpg_config = - - prefix = $ ( PREFIX ) - - extra - version = " kodi - $ ( VERSION ) " <nl> ffmpg_config + = - - cc = " $ ( CC ) " - - cxx = " $ ( CXX ) " - - ar = $ ( AR ) - - ranlib = $ ( RANLIB ) <nl> ffmpg_config + = - - disable - devices - - disable - doc <nl> - ffmpg_config + = - - disable - ffplay - - disable - ffmpeg - - disable - sdl <nl> + ffmpg_config + = - - disable - ffplay - - disable - ffmpeg <nl> ffmpg_config + = - - disable - ffprobe - - disable - ffserver <nl> ffmpg_config + = - - enable - gpl - - enable - runtime - cpudetect <nl> ffmpg_config + = - - enable - postproc - - enable - pthreads <nl> ifeq ( $ ( OS ) , android ) <nl> ffmpg_config + = - - cpu = i686 - - disable - mmx <nl> endif <nl> endif <nl> - ffmpg_config + = - - target - os = linux - - extra - libs = - liconv <nl> + ffmpg_config + = - - target - os = linux - - extra - libs = - liconv - - disable - linux - perf <nl> endif <nl> ifeq ( $ ( OS ) , ios ) <nl> ifneq ( $ ( CPU ) , arm64 ) <nl> ifeq ( $ ( OS ) , ios ) <nl> ffmpg_config + = - - target - os = darwin <nl> endif <nl> ifeq ( $ ( OS ) , osx ) <nl> - ffmpg_config + = - - disable - outdev = sdl <nl> ffmpg_config + = - - disable - decoder = mpeg_xvmc - - disable - vda - - disable - crystalhd - - enable - videotoolbox <nl> ffmpg_config + = - - target - os = darwin <nl> ffmpg_config + = - - disable - securetransport <nl> mmm a / tools / depends / target / ffmpeg / autobuild . sh <nl> ppp b / tools / depends / target / ffmpeg / autobuild . sh <nl> CFLAGS = " $ CFLAGS " CXXFLAGS = " $ CXXFLAGS " LDFLAGS = " $ LDFLAGS " \ <nl> - - disable - devices \ <nl> - - disable - ffplay \ <nl> - - disable - ffmpeg \ <nl> - - - disable - sdl \ <nl> - - disable - ffprobe \ <nl> - - disable - ffserver \ <nl> - - disable - doc \ <nl> | bump ffmpeg to 3 . 4 | xbmc/xbmc | a9f15a02b148e0cac470d9136de39cdc02ceb553 | 2017-10-15T14:33:00Z |
mmm a / include / spdlog / details / logger_impl . h <nl> ppp b / include / spdlog / details / logger_impl . h <nl> inline void spdlog : : logger : : sink_it_ ( details : : log_msg & msg ) <nl> <nl> if ( should_flush_ ( msg ) ) <nl> { <nl> - flush ( ) ; <nl> + flush_ ( ) ; <nl> } <nl> } <nl> <nl> | call flush_ ( ) instead of flush ( ) from looger : : sink_it_ ( ) | gabime/spdlog | 1293af093c11cecca0058980f6e1521cc857ef43 | 2018-11-24T09:11:03Z |
mmm a / xbmc / pvr / channels / PVRChannelGroupsContainer . cpp <nl> ppp b / xbmc / pvr / channels / PVRChannelGroupsContainer . cpp <nl> CPVRChannelGroupPtr CPVRChannelGroupsContainer : : GetSelectedGroup ( bool bRadio ) co <nl> return Get ( bRadio ) - > GetSelectedGroup ( ) ; <nl> } <nl> <nl> - CPVRChannelPtr CPVRChannelGroupsContainer : : GetByUniqueID ( int iClientChannelNumber , int iClientID ) <nl> + CPVRChannelPtr CPVRChannelGroupsContainer : : GetByUniqueID ( int iUniqueChannelId , int iClientID ) <nl> { <nl> CPVRChannelPtr channel ; <nl> CPVRChannelGroupPtr channelgroup = GetGroupAllTV ( ) ; <nl> if ( channelgroup ) <nl> - channel = channelgroup - > GetByClient ( iClientChannelNumber , iClientID ) ; <nl> + channel = channelgroup - > GetByClient ( iUniqueChannelId , iClientID ) ; <nl> <nl> if ( ! channelgroup | | ! channel ) <nl> channelgroup = GetGroupAllRadio ( ) ; <nl> if ( channelgroup ) <nl> - channel = channelgroup - > GetByClient ( iClientChannelNumber , iClientID ) ; <nl> + channel = channelgroup - > GetByClient ( iUniqueChannelId , iClientID ) ; <nl> <nl> return channel ; <nl> } <nl> mmm a / xbmc / pvr / channels / PVRChannelGroupsContainer . h <nl> ppp b / xbmc / pvr / channels / PVRChannelGroupsContainer . h <nl> namespace PVR <nl> <nl> / * ! <nl> * @ brief Get a channel given it ' s channel ID from all containers . <nl> - * @ param iClientChannelNumber The channel number on the client . <nl> + * @ param iUniqueChannelId The unique channel id on the client . <nl> * @ param iClientID The ID of the client . <nl> * @ return The channel or NULL if it wasn ' t found . <nl> * / <nl> - CPVRChannelPtr GetByUniqueID ( int iClientChannelNumber , int iClientID ) ; <nl> + CPVRChannelPtr GetByUniqueID ( int iUniqueChannelId , int iClientID ) ; <nl> <nl> / * ! <nl> * @ brief Get a channel given it ' s channel ID from all containers . <nl> | [ pvr ] fixed invalid param name and doxy | xbmc/xbmc | 97db72901d870e8f429c2e7eb5694039840be45a | 2012-10-09T20:29:14Z |
mmm a / src / mongo / db / storage / storage_engine_lock_file_posix . cpp <nl> ppp b / src / mongo / db / storage / storage_engine_lock_file_posix . cpp <nl> Status StorageEngineLockFile : : open ( ) { <nl> : : open ( _filespec . c_str ( ) , O_RDWR | O_CREAT , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ; <nl> if ( lockFile < 0 ) { <nl> int errorcode = errno ; <nl> + if ( errorcode = = EACCES ) { <nl> + return Status ( ErrorCodes : : IllegalOperation , <nl> + str : : stream ( ) <nl> + < < " Attempted to create a lock file on a read - only directory : " <nl> + < < _dbpath < < " - did you mean to start with - - readOnly ? " ) ; <nl> + } <nl> return Status ( ErrorCodes : : DBPathInUse , <nl> str : : stream ( ) < < " Unable to create / open lock file : " < < _filespec < < ' ' <nl> < < errnoWithDescription ( errorcode ) <nl> mmm a / src / mongo / db / storage / storage_engine_lock_file_test . cpp <nl> ppp b / src / mongo / db / storage / storage_engine_lock_file_test . cpp <nl> <nl> # include " mongo / unittest / temp_dir . h " <nl> # include " mongo / unittest / unittest . h " <nl> <nl> + # ifndef _WIN32 <nl> + # include < sys / stat . h > <nl> + # endif <nl> + <nl> namespace { <nl> <nl> using std : : string ; <nl> TEST ( StorageEngineLockFileTest , ClearPidAndUnlock ) { <nl> ASSERT_EQUALS ( 0U , boost : : filesystem : : file_size ( lockFile . getFilespec ( ) ) ) ; <nl> } <nl> <nl> + class ScopedReadOnlyDirectory { <nl> + public : <nl> + ScopedReadOnlyDirectory ( const std : : string & path ) : _path ( std : : move ( path ) ) { <nl> + _applyToPathRecursive ( _path , makePathReadOnly ) ; <nl> + } <nl> + <nl> + ~ ScopedReadOnlyDirectory ( ) { <nl> + _applyToPathRecursive ( _path , makePathWritable ) ; <nl> + } <nl> + <nl> + private : <nl> + const std : : string & _path ; <nl> + <nl> + static void makePathReadOnly ( const boost : : filesystem : : path & path ) { <nl> + # ifdef _WIN32 <nl> + : : SetFileAttributes ( path . c_str ( ) , FILE_ATTRIBUTE_READONLY ) ; <nl> + # else <nl> + : : chmod ( path . c_str ( ) , 0544 ) ; <nl> + # endif <nl> + } <nl> + <nl> + static void makePathWritable ( const boost : : filesystem : : path & path ) { <nl> + # ifdef _WIN32 <nl> + : : SetFileAttributes ( path . c_str ( ) , FILE_ATTRIBUTE_NORMAL ) ; <nl> + # else <nl> + : : chmod ( path . c_str ( ) , 0777 ) ; <nl> + # endif <nl> + } <nl> + <nl> + template < typename Func > <nl> + static void _applyToPathRecursive ( const boost : : filesystem : : path & path , Func func ) { <nl> + func ( path ) ; <nl> + <nl> + using rdi = boost : : filesystem : : recursive_directory_iterator ; <nl> + for ( auto iter = rdi { path } ; iter ! = rdi ( ) ; + + iter ) { <nl> + func ( * iter ) ; <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + # ifndef _WIN32 <nl> + <nl> + / / Windows has no concept of read only directories - only read only files . <nl> + TEST ( StorageEngineLockFileTest , ReadOnlyDirectory ) { <nl> + TempDir tempDir ( " StorageEngineLockFileTest_ReadOnlyDirectory " ) ; <nl> + <nl> + / / Make tempDir read - only . <nl> + ScopedReadOnlyDirectory srod ( tempDir . path ( ) ) ; <nl> + <nl> + StorageEngineLockFile lockFile ( tempDir . path ( ) ) ; <nl> + <nl> + auto openStatus = lockFile . open ( ) ; <nl> + <nl> + ASSERT_NOT_OK ( openStatus ) ; <nl> + ASSERT_EQ ( openStatus , ErrorCodes : : IllegalOperation ) ; <nl> + } <nl> + <nl> + # endif <nl> + <nl> + TEST ( StorageEngineLockFileTest , ReadOnlyDirectoryWithLockFile ) { <nl> + TempDir tempDir ( " StorageEngineLockFileTest_ReadOnlyDirectoryWithLockFile " ) ; <nl> + <nl> + StorageEngineLockFile lockFile ( tempDir . path ( ) ) ; <nl> + ASSERT_OK ( lockFile . open ( ) ) ; <nl> + ASSERT_OK ( lockFile . writePid ( ) ) ; <nl> + <nl> + / / Make tempDir read - only . <nl> + ScopedReadOnlyDirectory srod ( tempDir . path ( ) ) ; <nl> + <nl> + / / Try to create a new lock file . <nl> + StorageEngineLockFile lockFile2 ( tempDir . path ( ) ) ; <nl> + <nl> + auto openStatus = lockFile2 . open ( ) ; <nl> + <nl> + ASSERT_NOT_OK ( openStatus ) ; <nl> + ASSERT_EQ ( openStatus , ErrorCodes : : IllegalOperation ) ; <nl> + } <nl> + <nl> } / / namespace <nl> mmm a / src / mongo / db / storage / storage_engine_lock_file_windows . cpp <nl> ppp b / src / mongo / db / storage / storage_engine_lock_file_windows . cpp <nl> Status StorageEngineLockFile : : open ( ) { <nl> <nl> if ( lockFileHandle = = INVALID_HANDLE_VALUE ) { <nl> int errorcode = GetLastError ( ) ; <nl> + if ( errorcode = = ERROR_ACCESS_DENIED ) { <nl> + return Status ( ErrorCodes : : IllegalOperation , <nl> + str : : stream ( ) <nl> + < < " Attempted to create a lock file on a read - only directory : " <nl> + < < _dbpath < < " - did you mean to start with - - readOnly ? " ) ; <nl> + } <nl> return Status ( ErrorCodes : : DBPathInUse , <nl> str : : stream ( ) < < " Unable to create / open lock file : " < < _filespec < < ' ' <nl> < < errnoWithDescription ( errorcode ) <nl> | SERVER - 22352 lockFile changes for readOnly | mongodb/mongo | 77191d85a8a42d28cd32ce37365defae23556069 | 2016-02-05T20:20:26Z |
mmm a / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> const auto ERROR_SLEEP_MS = 1000 ; <nl> - <nl> - / / / Если ждём какого - то события с помощью watch - а , то просыпаться на всякий случай вхолостую раз в указанное время . <nl> - const auto WAIT_FOR_NEW_LOGS_SLEEP_MS = 60 * 1000 ; <nl> - const auto WAIT_FOR_ALTER_SLEEP_MS = 300 * 1000 ; <nl> - const auto WAIT_FOR_REPLICA_QUEUE_MS = 10 * 1000 ; <nl> - <nl> const auto MERGE_SELECTING_SLEEP_MS = 5 * 1000 ; <nl> <nl> / * * Добавляемым блокам данных присваиваются некоторые номера - целые числа . <nl> void StorageReplicatedMergeTree : : queueUpdatingThread ( ) <nl> try <nl> { <nl> pullLogsToQueue ( queue_updating_event ) ; <nl> - queue_updating_event - > tryWait ( WAIT_FOR_NEW_LOGS_SLEEP_MS ) ; <nl> + queue_updating_event - > wait ( ) ; <nl> } <nl> catch ( const zkutil : : KeeperException & e ) <nl> { <nl> void StorageReplicatedMergeTree : : alterThread ( ) <nl> / / / Важно , что уничтожается parts и merge_blocker перед wait - ом . <nl> } <nl> <nl> - alter_thread_event - > tryWait ( WAIT_FOR_ALTER_SLEEP_MS ) ; <nl> + alter_thread_event - > wait ( ) ; <nl> } <nl> catch ( . . . ) <nl> { <nl> void StorageReplicatedMergeTree : : alter ( const AlterCommands & params , <nl> if ( stat . version ! = replica_columns_version ) <nl> continue ; <nl> <nl> - alter_query_event - > tryWait ( WAIT_FOR_ALTER_SLEEP_MS ) ; <nl> + alter_query_event - > wait ( ) ; <nl> } <nl> <nl> if ( shutdown_called ) <nl> void StorageReplicatedMergeTree : : waitForReplicaToProcessLogEntry ( const String & <nl> if ( ! log_pointer . empty ( ) & & parse < UInt64 > ( log_pointer ) > log_index ) <nl> break ; <nl> <nl> - event - > tryWait ( WAIT_FOR_REPLICA_QUEUE_MS ) ; <nl> + event - > wait ( ) ; <nl> } <nl> } <nl> else if ( 0 = = entry . znode_name . compare ( 0 , strlen ( " queue - " ) , " queue - " ) ) <nl> void StorageReplicatedMergeTree : : waitForReplicaToProcessLogEntry ( const String & <nl> if ( ! log_pointer . empty ( ) & & parse < UInt64 > ( log_pointer ) > log_index ) <nl> break ; <nl> <nl> - event - > tryWait ( WAIT_FOR_REPLICA_QUEUE_MS ) ; <nl> + event - > wait ( ) ; <nl> } <nl> } <nl> } <nl> | Fixed error with leak of watches [ # METR - 19975 ] . | ClickHouse/ClickHouse | d14a12151e8af82daaa3dfca593f3b8262827162 | 2016-02-11T01:48:34Z |
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class alignas ( 1 < < DeclAlignInBits ) Decl { <nl> IsStatic : 1 <nl> ) ; <nl> <nl> - SWIFT_INLINE_BITFIELD ( VarDecl , AbstractStorageDecl , 1 + 1 + 1 + 1 + 1 + 1 + 1 , <nl> + SWIFT_INLINE_BITFIELD ( VarDecl , AbstractStorageDecl , 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 , <nl> / / / Encodes whether this is a ' let ' binding . <nl> Introducer : 1 , <nl> <nl> class alignas ( 1 < < DeclAlignInBits ) Decl { <nl> IsLazyStorageProperty : 1 , <nl> <nl> / / / Whether this is the backing storage for a property wrapper . <nl> - IsPropertyWrapperBackingProperty : 1 <nl> + IsPropertyWrapperBackingProperty : 1 , <nl> + <nl> + / / / Whether this is a lazily top - level global variable from the main file . <nl> + IsTopLevelGlobal : 1 <nl> ) ; <nl> <nl> SWIFT_INLINE_BITFIELD ( ParamDecl , VarDecl , 1 + 2 + NumDefaultArgumentKindBits , <nl> class VarDecl : public AbstractStorageDecl { <nl> Bits . VarDecl . IsLazyStorageProperty = IsLazyStorage ; <nl> } <nl> <nl> + / / / True if this is a top - level global variable from the main source file . <nl> + bool isTopLevelGlobal ( ) const { return Bits . VarDecl . IsTopLevelGlobal ; } <nl> + void setTopLevelGlobal ( bool b ) { Bits . VarDecl . IsTopLevelGlobal = b ; } <nl> + <nl> / / / Retrieve the custom attributes that attach property wrappers to this <nl> / / / property . The returned list contains all of the attached property wrapper attributes in source order , <nl> / / / which means the outermost wrapper attribute is provided first . <nl> mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> NOTE ( candidate_expected_different_labels , none , <nl> " incorrect labels for candidate ( have : ' % 0 ' , expected : ' % 1 ' ) " , <nl> ( StringRef , StringRef ) ) <nl> <nl> + ERROR ( member_shadows_function , none , <nl> + " use of % 0 refers to % 1 rather than % 2 % 3 " , <nl> + ( DeclNameRef , DescriptiveDeclKind , DescriptiveDeclKind , DeclName ) ) <nl> ERROR ( member_shadows_global_function , none , <nl> - " use of % 0 refers to % 1 % 2 rather than % 3 % 4 in % 5 % 6 " , <nl> - ( DeclNameRef , DescriptiveDeclKind , DeclName , DescriptiveDeclKind , <nl> - DeclName , DescriptiveDeclKind , DeclName ) ) <nl> - ERROR ( member_shadows_global_function_near_match , none , <nl> - " use of % 0 nearly matches % 3 % 4 in % 5 % 6 rather than % 1 % 2 " , <nl> - ( DeclNameRef , DescriptiveDeclKind , DeclName , DescriptiveDeclKind , <nl> - DeclName , DescriptiveDeclKind , DeclName ) ) <nl> + " use of % 0 refers to % 1 rather than % 2 % 3 in module % 4 " , <nl> + ( DeclNameRef , DescriptiveDeclKind , DescriptiveDeclKind , DeclName , DeclName ) ) <nl> <nl> ERROR ( instance_member_use_on_type , none , <nl> " instance member % 1 cannot be used on type % 0 ; " <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> VarDecl : : VarDecl ( DeclKind kind , bool isStatic , VarDecl : : Introducer introducer , <nl> Bits . VarDecl . IsLazyStorageProperty = false ; <nl> Bits . VarDecl . HasNonPatternBindingInit = false ; <nl> Bits . VarDecl . IsPropertyWrapperBackingProperty = false ; <nl> + Bits . VarDecl . IsTopLevelGlobal = false ; <nl> } <nl> <nl> Type VarDecl : : getType ( ) const { <nl> bool VarDecl : : isLazilyInitializedGlobal ( ) const { <nl> <nl> / / Top - level global variables in the main source file and in the REPL are not <nl> / / lazily initialized . <nl> - auto sourceFileContext = dyn_cast < SourceFile > ( getDeclContext ( ) ) ; <nl> - if ( ! sourceFileContext ) <nl> - return true ; <nl> - <nl> - return ! sourceFileContext - > isScriptMode ( ) ; <nl> + return ! isTopLevelGlobal ( ) ; <nl> } <nl> <nl> SourceRange VarDecl : : getSourceRange ( ) const { <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> Parser : : parseDeclVar ( ParseDeclOptions Flags , <nl> VD - > setStatic ( StaticLoc . isValid ( ) ) ; <nl> VD - > getAttrs ( ) = Attributes ; <nl> setLocalDiscriminator ( VD ) ; <nl> + VD - > setTopLevelGlobal ( topLevelDecl ) ; <nl> <nl> / / Set original declaration in ` @ differentiable ` attributes . <nl> setOriginalDeclarationForDifferentiableAttributes ( Attributes , VD ) ; <nl> mmm a / lib / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SILGen / SILGenExpr . cpp <nl> RValue RValueEmitter : : visitMakeTemporarilyEscapableExpr ( <nl> return visit ( E - > getSubExpr ( ) , C ) ; <nl> } ; <nl> <nl> - / / Handle @ convention ( block ) . No withoutActuallyEscaping verification yet . <nl> - if ( silFnTy - > getExtInfo ( ) . getRepresentation ( ) ! = <nl> - SILFunctionTypeRepresentation : : Thick ) { <nl> + / / Handle @ convention ( block ) an @ convention ( c ) . No withoutActuallyEscaping <nl> + / / verification yet . <nl> + auto closureRepresentation = silFnTy - > getExtInfo ( ) . getRepresentation ( ) ; <nl> + if ( closureRepresentation ! = SILFunctionTypeRepresentation : : Thick ) { <nl> auto escapingClosure = <nl> SGF . B . createConvertFunction ( E , functionValue , escapingFnTy , <nl> / * WithoutActuallyEscaping = * / true ) ; <nl> - return visitSubExpr ( escapingClosure , true / * isClosureConsumable * / ) ; <nl> + bool isBlockConvention = <nl> + closureRepresentation = = SILFunctionTypeRepresentation : : Block ; <nl> + return visitSubExpr ( escapingClosure , <nl> + isBlockConvention / * isClosureConsumable * / ) ; <nl> } <nl> <nl> / / Convert it to an escaping function value . <nl> mmm a / lib / Sema / CSDiag . cpp <nl> ppp b / lib / Sema / CSDiag . cpp <nl> class FailureDiagnosis : public ASTVisitor < FailureDiagnosis , / * exprresult * / bool > { <nl> ContextualTypePurpose CTP , <nl> Type suggestedType = Type ( ) ) ; <nl> <nl> - bool diagnoseImplicitSelfErrors ( Expr * fnExpr , Expr * argExpr , <nl> - CalleeCandidateInfo & CCI , <nl> - ArrayRef < Identifier > argLabels ) ; <nl> - <nl> private : <nl> / / / Validate potential contextual type for type - checking one of the <nl> / / / sub - expressions , usually correct / valid types are the ones which <nl> decomposeArgType ( Type argType , ArrayRef < Identifier > argLabels ) { <nl> return result ; <nl> } <nl> <nl> - bool FailureDiagnosis : : diagnoseImplicitSelfErrors ( <nl> - Expr * fnExpr , Expr * argExpr , CalleeCandidateInfo & CCI , <nl> - ArrayRef < Identifier > argLabels ) { <nl> - / / If candidate list is empty it means that problem is somewhere else , <nl> - / / since we need to have candidates which might be shadowing other funcs . <nl> - if ( CCI . empty ( ) | | ! CCI [ 0 ] . getDecl ( ) ) <nl> - return false ; <nl> - <nl> - auto & ctx = CS . getASTContext ( ) ; <nl> - / / Call expression is formed as ' foo . bar ' where ' foo ' might be an <nl> - / / implicit " Self " reference , such use wouldn ' t provide good diagnostics <nl> - / / for situations where instance members have equal names to functions in <nl> - / / Swift Standard Library e . g . min / max . <nl> - auto UDE = dyn_cast < UnresolvedDotExpr > ( fnExpr ) ; <nl> - if ( ! UDE ) <nl> - return false ; <nl> - <nl> - auto baseExpr = dyn_cast < DeclRefExpr > ( UDE - > getBase ( ) ) ; <nl> - if ( ! baseExpr ) <nl> - return false ; <nl> - <nl> - auto baseDecl = baseExpr - > getDecl ( ) ; <nl> - if ( ! baseExpr - > isImplicit ( ) | | baseDecl - > getFullName ( ) ! = ctx . Id_self ) <nl> - return false ; <nl> - <nl> - / / Our base expression is an implicit ' self . ' reference e . g . <nl> - / / <nl> - / / extension Sequence { <nl> - / / func test ( ) - > Int { <nl> - / / return max ( 1 , 2 ) <nl> - / / } <nl> - / / } <nl> - / / <nl> - / / In this example the Sequence class already has two methods named ' max ' <nl> - / / none of which accept two arguments , but there is a function in <nl> - / / Swift Standard Library called ' max ' which does accept two arguments , <nl> - / / so user might have called that by mistake without realizing that <nl> - / / compiler would add implicit ' self . ' prefix to the call of ' max ' . <nl> - auto argType = CS . getType ( argExpr ) ; <nl> - / / If argument wasn ' t properly type - checked , let ' s retry without changing AST . <nl> - if ( ! argType | | argType - > hasUnresolvedType ( ) | | argType - > hasTypeVariable ( ) | | <nl> - argType - > hasTypeParameter ( ) ) { <nl> - auto * argTuple = dyn_cast < TupleExpr > ( argExpr ) ; <nl> - if ( ! argTuple ) { <nl> - / / Bail out if we don ' t have a well - formed argument list . <nl> - return false ; <nl> - } <nl> - <nl> - / / Let ' s type check individual argument expressions without any <nl> - / / contextual information to try to recover an argument type that <nl> - / / matches what the user actually wrote instead of what the typechecker <nl> - / / expects . <nl> - SmallVector < TupleTypeElt , 4 > elts ; <nl> - for ( unsigned i = 0 , e = argTuple - > getNumElements ( ) ; i < e ; + + i ) { <nl> - ConcreteDeclRef ref = nullptr ; <nl> - auto * el = argTuple - > getElement ( i ) ; <nl> - auto typeResult = <nl> - TypeChecker : : getTypeOfExpressionWithoutApplying ( el , CS . DC , ref ) ; <nl> - if ( ! typeResult ) <nl> - return false ; <nl> - auto flags = ParameterTypeFlags ( ) . withInOut ( typeResult - > is < InOutType > ( ) ) ; <nl> - elts . push_back ( TupleTypeElt ( typeResult - > getInOutObjectType ( ) , <nl> - argTuple - > getElementName ( i ) , <nl> - flags ) ) ; <nl> - } <nl> - <nl> - argType = TupleType : : get ( elts , CS . getASTContext ( ) ) ; <nl> - } <nl> - <nl> - auto typeKind = argType - > getKind ( ) ; <nl> - if ( typeKind ! = TypeKind : : Tuple & & typeKind ! = TypeKind : : Paren ) <nl> - return false ; <nl> - <nl> - / / If argument type couldn ' t be properly resolved or has errors , <nl> - / / we can ' t diagnose anything in here , it points to the different problem . <nl> - if ( isUnresolvedOrTypeVarType ( argType ) | | argType - > hasError ( ) ) <nl> - return false ; <nl> - <nl> - auto context = CS . DC ; <nl> - using CandidateMap = <nl> - llvm : : SmallDenseMap < ValueDecl * , llvm : : SmallVector < OverloadChoice , 2 > > ; <nl> - <nl> - auto getBaseKind = [ ] ( ValueDecl * base ) - > DescriptiveDeclKind { <nl> - DescriptiveDeclKind kind = DescriptiveDeclKind : : Module ; <nl> - if ( ! base ) <nl> - return kind ; <nl> - <nl> - auto context = base - > getDeclContext ( ) ; <nl> - do { <nl> - if ( isa < ExtensionDecl > ( context ) ) <nl> - return DescriptiveDeclKind : : Extension ; <nl> - <nl> - if ( auto nominal = dyn_cast < NominalTypeDecl > ( context ) ) { <nl> - kind = nominal - > getDescriptiveKind ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - context = context - > getParent ( ) ; <nl> - } while ( context ) ; <nl> - <nl> - return kind ; <nl> - } ; <nl> - <nl> - auto diagnoseShadowing = [ & ] ( ValueDecl * base , <nl> - ArrayRef < OverloadChoice > candidates ) - > bool { <nl> - CalleeCandidateInfo calleeInfo ( base ? base - > getInterfaceType ( ) : nullptr , <nl> - candidates , CCI . hasTrailingClosure , CS , <nl> - base ) ; <nl> - <nl> - calleeInfo . filterListArgs ( decomposeArgType ( argType , argLabels ) ) ; <nl> - <nl> - auto diagnostic = diag : : member_shadows_global_function_near_match ; <nl> - switch ( calleeInfo . closeness ) { <nl> - case CC_Unavailable : <nl> - case CC_Inaccessible : <nl> - case CC_SelfMismatch : <nl> - case CC_ArgumentLabelMismatch : <nl> - case CC_ArgumentCountMismatch : <nl> - case CC_GeneralMismatch : <nl> - return false ; <nl> - <nl> - case CC_NonLValueInOut : <nl> - case CC_OneArgumentNearMismatch : <nl> - case CC_OneArgumentMismatch : <nl> - case CC_OneGenericArgumentNearMismatch : <nl> - case CC_OneGenericArgumentMismatch : <nl> - case CC_ArgumentNearMismatch : <nl> - case CC_ArgumentMismatch : <nl> - case CC_GenericNonsubstitutableMismatch : <nl> - break ; / / Near match cases <nl> - <nl> - case CC_ExactMatch : <nl> - diagnostic = diag : : member_shadows_global_function ; <nl> - break ; <nl> - } <nl> - <nl> - auto choice = calleeInfo . candidates [ 0 ] . getDecl ( ) ; <nl> - auto baseKind = getBaseKind ( base ) ; <nl> - auto baseName = getBaseName ( choice - > getDeclContext ( ) ) ; <nl> - <nl> - auto origCandidate = CCI [ 0 ] . getDecl ( ) ; <nl> - ctx . Diags . diagnose ( UDE - > getLoc ( ) , diagnostic , UDE - > getName ( ) , <nl> - origCandidate - > getDescriptiveKind ( ) , <nl> - origCandidate - > getFullName ( ) , <nl> - choice - > getDescriptiveKind ( ) , <nl> - choice - > getFullName ( ) , baseKind , baseName ) ; <nl> - <nl> - auto topLevelDiag = diag : : fix_unqualified_access_top_level ; <nl> - if ( baseKind = = DescriptiveDeclKind : : Module ) <nl> - topLevelDiag = diag : : fix_unqualified_access_top_level_multi ; <nl> - <nl> - emitFixItForExplicitlyQualifiedReference ( ctx . Diags , UDE , topLevelDiag , <nl> - baseName , <nl> - choice - > getDescriptiveKind ( ) ) ; <nl> - <nl> - for ( auto & candidate : calleeInfo . candidates ) { <nl> - if ( auto decl = candidate . getDecl ( ) ) <nl> - ctx . Diags . diagnose ( decl , diag : : decl_declared_here , decl - > getFullName ( ) ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } ; <nl> - <nl> - / / For each of the parent contexts , let ' s try to find any candidates <nl> - / / which have the same name and the same number of arguments as callee . <nl> - while ( context - > getParent ( ) ) { <nl> - auto result = <nl> - TypeChecker : : lookupUnqualified ( context , UDE - > getName ( ) , UDE - > getLoc ( ) ) ; <nl> - context = context - > getParent ( ) ; <nl> - <nl> - if ( ! result | | result . empty ( ) ) <nl> - continue ; <nl> - <nl> - CandidateMap candidates ; <nl> - for ( const auto & candidate : result ) { <nl> - auto base = candidate . getBaseDecl ( ) ; <nl> - auto decl = candidate . getValueDecl ( ) ; <nl> - if ( ( base & & base - > isInvalid ( ) ) | | decl - > isInvalid ( ) ) <nl> - continue ; <nl> - <nl> - / / If base is present but it doesn ' t represent a valid nominal , <nl> - / / we can ' t use current candidate as one of the choices . <nl> - if ( base & & ! base - > getInterfaceType ( ) - > getNominalOrBoundGenericNominal ( ) ) <nl> - continue ; <nl> - <nl> - auto context = decl - > getDeclContext ( ) ; <nl> - / / We are only interested in static or global functions , because <nl> - / / there is no way to call anything else properly . <nl> - if ( ! decl - > isStatic ( ) & & ! context - > isModuleScopeContext ( ) ) <nl> - continue ; <nl> - <nl> - OverloadChoice choice ( base ? base - > getInterfaceType ( ) : nullptr , <nl> - decl , UDE - > getFunctionRefKind ( ) ) ; <nl> - <nl> - if ( base ) { / / Let ' s group all of the candidates have a common base . <nl> - candidates [ base ] . push_back ( choice ) ; <nl> - continue ; <nl> - } <nl> - <nl> - / / If there is no base , it means this is one of the global functions , <nl> - / / let ' s try to diagnose its shadowing inline . <nl> - if ( diagnoseShadowing ( base , choice ) ) <nl> - return true ; <nl> - } <nl> - <nl> - if ( candidates . empty ( ) ) <nl> - continue ; <nl> - <nl> - for ( const auto & candidate : candidates ) { <nl> - if ( diagnoseShadowing ( candidate . getFirst ( ) , candidate . getSecond ( ) ) ) <nl> - return true ; <nl> - } <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> / / Extract expression for failed argument number <nl> static Expr * getFailedArgumentExpr ( CalleeCandidateInfo CCI , Expr * argExpr ) { <nl> if ( auto * TE = dyn_cast < TupleExpr > ( argExpr ) ) <nl> static Expr * getFailedArgumentExpr ( CalleeCandidateInfo CCI , Expr * argExpr ) { <nl> bool FailureDiagnosis : : diagnoseParameterErrors ( CalleeCandidateInfo & CCI , <nl> Expr * fnExpr , Expr * argExpr , <nl> ArrayRef < Identifier > argLabels ) { <nl> - / / Try to diagnose errors related to the use of implicit self reference . <nl> - if ( diagnoseImplicitSelfErrors ( fnExpr , argExpr , CCI , argLabels ) ) <nl> - return true ; <nl> - <nl> / / If we have a failure where the candidate set differs on exactly one <nl> / / argument , and where we have a consistent mismatch across the candidate set <nl> / / ( often because there is only one candidate in the set ) , then diagnose this <nl> mmm a / lib / Sema / CSDiagnostics . cpp <nl> ppp b / lib / Sema / CSDiagnostics . cpp <nl> bool UnableToInferProtocolLiteralType : : diagnoseAsError ( ) { <nl> <nl> return true ; <nl> } <nl> + <nl> + bool MissingQuialifierInMemberRefFailure : : diagnoseAsError ( ) { <nl> + auto selectedOverload = getOverloadChoiceIfAvailable ( getLocator ( ) ) ; <nl> + if ( ! selectedOverload ) <nl> + return false ; <nl> + <nl> + auto * UDE = cast < UnresolvedDotExpr > ( getRawAnchor ( ) ) ; <nl> + <nl> + auto baseType = getType ( UDE - > getBase ( ) ) ; <nl> + <nl> + auto methodKind = baseType - > isAnyExistentialType ( ) <nl> + ? DescriptiveDeclKind : : StaticMethod <nl> + : DescriptiveDeclKind : : Method ; <nl> + <nl> + auto choice = selectedOverload - > choice . getDeclOrNull ( ) ; <nl> + if ( ! choice ) <nl> + return false ; <nl> + <nl> + auto * DC = choice - > getDeclContext ( ) ; <nl> + if ( ! ( DC - > isModuleContext ( ) | | DC - > isModuleScopeContext ( ) ) ) { <nl> + emitDiagnostic ( UDE - > getLoc ( ) , diag : : member_shadows_function , UDE - > getName ( ) , <nl> + methodKind , choice - > getDescriptiveKind ( ) , <nl> + choice - > getFullName ( ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> + auto qualifier = DC - > getParentModule ( ) - > getName ( ) ; <nl> + <nl> + emitDiagnostic ( UDE - > getLoc ( ) , diag : : member_shadows_global_function , <nl> + UDE - > getName ( ) , methodKind , choice - > getDescriptiveKind ( ) , <nl> + choice - > getFullName ( ) , qualifier ) ; <nl> + <nl> + SmallString < 32 > namePlusDot = qualifier . str ( ) ; <nl> + namePlusDot . push_back ( ' . ' ) ; <nl> + <nl> + emitDiagnostic ( UDE - > getLoc ( ) , diag : : fix_unqualified_access_top_level_multi , <nl> + namePlusDot , choice - > getDescriptiveKind ( ) , qualifier ) <nl> + . fixItInsert ( UDE - > getStartLoc ( ) , namePlusDot ) ; <nl> + <nl> + emitDiagnostic ( choice , diag : : decl_declared_here , choice - > getFullName ( ) ) ; <nl> + return true ; <nl> + } <nl> mmm a / lib / Sema / CSDiagnostics . h <nl> ppp b / lib / Sema / CSDiagnostics . h <nl> class UnableToInferProtocolLiteralType final : public FailureDiagnostic { <nl> bool diagnoseAsError ( ) ; <nl> } ; <nl> <nl> + / / / Diagnose an attempt to reference a top - level name shadowed by a local <nl> + / / / member e . g . <nl> + / / / <nl> + / / / ` ` ` swift <nl> + / / / extension Sequence { <nl> + / / / func test ( ) - > Int { <nl> + / / / return max ( 1 , 2 ) <nl> + / / / } <nl> + / / / } <nl> + / / / ` ` ` <nl> + / / / <nl> + / / / Here ` max ` refers to a global function ` max < T > ( _ : T , _ : T ) ` in ` Swift ` <nl> + / / / module and can only be accessed by adding ` Swift . ` to it , because ` Sequence ` <nl> + / / / has a member named ` max ` which accepts a single argument . <nl> + class MissingQuialifierInMemberRefFailure final : public FailureDiagnostic { <nl> + public : <nl> + MissingQuialifierInMemberRefFailure ( ConstraintSystem & cs , <nl> + ConstraintLocator * locator ) <nl> + : FailureDiagnostic ( cs , locator ) { } <nl> + <nl> + bool diagnoseAsError ( ) ; <nl> + } ; <nl> + <nl> } / / end namespace constraints <nl> } / / end namespace swift <nl> <nl> mmm a / lib / Sema / CSFix . cpp <nl> ppp b / lib / Sema / CSFix . cpp <nl> AllowNonClassTypeToConvertToAnyObject : : create ( ConstraintSystem & cs , Type type , <nl> return new ( cs . getAllocator ( ) ) <nl> AllowNonClassTypeToConvertToAnyObject ( cs , type , locator ) ; <nl> } <nl> + <nl> + bool AddQualifierToAccessTopLevelName : : diagnose ( bool asNote ) const { <nl> + auto & cs = getConstraintSystem ( ) ; <nl> + MissingQuialifierInMemberRefFailure failure ( cs , getLocator ( ) ) ; <nl> + return failure . diagnose ( asNote ) ; <nl> + } <nl> + <nl> + AddQualifierToAccessTopLevelName * <nl> + AddQualifierToAccessTopLevelName : : create ( ConstraintSystem & cs , <nl> + ConstraintLocator * locator ) { <nl> + return new ( cs . getAllocator ( ) ) AddQualifierToAccessTopLevelName ( cs , locator ) ; <nl> + } <nl> mmm a / lib / Sema / CSFix . h <nl> ppp b / lib / Sema / CSFix . h <nl> enum class FixKind : uint8_t { <nl> / / / Allow any type ( and not just class or class - constrained type ) to <nl> / / / be convertible to AnyObject . <nl> AllowNonClassTypeToConvertToAnyObject , <nl> + <nl> + / / / Member shadows a top - level name , such a name could only be accessed by <nl> + / / / prefixing it with a module name . <nl> + AddQualifierToAccessTopLevelName , <nl> } ; <nl> <nl> class ConstraintFix { <nl> class SpecifyObjectLiteralTypeImport final : public ConstraintFix { <nl> <nl> static SpecifyObjectLiteralTypeImport * create ( ConstraintSystem & cs , <nl> ConstraintLocator * locator ) ; <nl> + } ; <nl> + <nl> + class AddQualifierToAccessTopLevelName final : public ConstraintFix { <nl> + AddQualifierToAccessTopLevelName ( ConstraintSystem & cs , <nl> + ConstraintLocator * locator ) <nl> + : ConstraintFix ( cs , FixKind : : AddQualifierToAccessTopLevelName , locator ) { } <nl> + <nl> + public : <nl> + std : : string getName ( ) const { <nl> + return " qualify reference to access top - level function " ; <nl> + } <nl> <nl> + bool diagnose ( bool asNote = false ) const ; <nl> + <nl> + static AddQualifierToAccessTopLevelName * create ( ConstraintSystem & cs , <nl> + ConstraintLocator * locator ) ; <nl> } ; <nl> <nl> class AllowNonClassTypeToConvertToAnyObject final : public ContextualMismatch { <nl> mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> bool ConstraintSystem : : repairFailures ( <nl> locator ) ) <nl> break ; <nl> <nl> + { <nl> + auto * calleeLocator = getCalleeLocator ( loc ) ; <nl> + if ( hasFixFor ( calleeLocator , FixKind : : AddQualifierToAccessTopLevelName ) ) { <nl> + if ( auto overload = findSelectedOverloadFor ( calleeLocator ) ) { <nl> + if ( auto choice = overload - > choice . getDeclOrNull ( ) ) { <nl> + / / If this is an argument of a symetric function / operator let ' s <nl> + / / not fix any position rather than first because we ' d just end <nl> + / / up with ambiguity instead of reporting an actual problem with <nl> + / / mismatched type since each argument can have district bindings . <nl> + if ( auto * AFD = dyn_cast < AbstractFunctionDecl > ( choice ) ) { <nl> + auto * paramList = AFD - > getParameters ( ) ; <nl> + auto firstParamType = paramList - > get ( 0 ) - > getInterfaceType ( ) ; <nl> + if ( elt . castTo < LocatorPathElt : : ApplyArgToParam > ( ) . getParamIdx ( ) > <nl> + 0 & & <nl> + llvm : : all_of ( * paramList , [ & ] ( const ParamDecl * param ) - > bool { <nl> + return param - > getInterfaceType ( ) - > isEqual ( firstParamType ) ; <nl> + } ) ) <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> conversionsOrFixes . push_back ( <nl> AllowArgumentMismatch : : create ( * this , lhs , rhs , loc ) ) ; <nl> break ; <nl> ConstraintSystem : : SolutionKind ConstraintSystem : : simplifyMemberConstraint ( <nl> if ( candidates . size ( ) = = 1 ) <nl> candidates . front ( ) - > setFavored ( ) ; <nl> <nl> - generateConstraints ( candidates , memberTy , outerAlternatives , <nl> - useDC , locator ) ; <nl> + / / We * might * include any non - members that we found in outer contexts in <nl> + / / some special cases , for backwards compatibility : first , we have to be <nl> + / / looking for one of the special names ( ' min ' or ' max ' ) , and second , all <nl> + / / of the inner ( viable ) results need to come from conditional <nl> + / / conformances . The second condition is how the problem here was <nl> + / / encountered : a type ( ' Range ' ) was made to conditionally conform to a <nl> + / / new protocol ( ' Sequence ' ) , which introduced some extra methods <nl> + / / ( ' min ' and ' max ' ) that shadowed global functions that people regularly <nl> + / / called within extensions to that type ( usually adding ' clamp ' ) . <nl> + bool treatAsViable = <nl> + ( member . isSimpleName ( " min " ) | | member . isSimpleName ( " max " ) ) & & <nl> + allFromConditionalConformances ( DC , baseTy , result . ViableCandidates ) ; <nl> + <nl> + generateConstraints ( <nl> + candidates , memberTy , outerAlternatives , useDC , locator , None , <nl> + / * requiresFix = * / ! treatAsViable , <nl> + [ & ] ( unsigned , const OverloadChoice & ) { <nl> + return treatAsViable ? nullptr <nl> + : AddQualifierToAccessTopLevelName : : create ( <nl> + * this , locator ) ; <nl> + } ) ; <nl> } <nl> } <nl> <nl> ConstraintSystem : : SolutionKind ConstraintSystem : : simplifyFixConstraint ( <nl> case FixKind : : AllowInvalidUseOfTrailingClosure : <nl> case FixKind : : AllowNonClassTypeToConvertToAnyObject : <nl> case FixKind : : SpecifyClosureReturnType : <nl> + case FixKind : : AddQualifierToAccessTopLevelName : <nl> llvm_unreachable ( " handled elsewhere " ) ; <nl> } <nl> <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> <nl> case ConstraintKind : : BindOverload : <nl> if ( auto * fix = constraint . getFix ( ) ) { <nl> - if ( recordFix ( fix ) ) <nl> + / / TODO ( diagnostics ) : Impact should be associated with a fix unless <nl> + / / it ' s a contextual problem , then only solver can decide what the impact <nl> + / / would be in each particular situation . <nl> + auto impact = <nl> + fix - > getKind ( ) = = FixKind : : AddQualifierToAccessTopLevelName ? 10 : 1 ; <nl> + if ( recordFix ( fix , impact ) ) <nl> return SolutionKind : : Error ; <nl> } <nl> <nl> mmm a / lib / Sema / TypeCheckConstraints . cpp <nl> ppp b / lib / Sema / TypeCheckConstraints . cpp <nl> static bool findNonMembers ( ArrayRef < LookupResultEntry > lookupResults , <nl> return AllDeclRefs ; <nl> } <nl> <nl> - / / / Whether we should be looking at the outer results for a function called \ c <nl> - / / / name . <nl> - / / / <nl> - / / / This is very restrictive because it ' s a source compatibility issue ( see the <nl> - / / / if ( AllConditionalConformances ) { ( void ) findNonMembers ( . . . ) ; } below ) . <nl> - static bool shouldConsiderOuterResultsFor ( DeclNameRef name ) { <nl> - const StringRef specialNames [ ] = { " min " , " max " } ; <nl> - for ( auto specialName : specialNames ) <nl> - if ( name . isSimpleName ( specialName ) ) <nl> - return true ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> / / / Bind an UnresolvedDeclRefExpr by performing name lookup and <nl> / / / returning the resultant expression . Context is the DeclContext used <nl> / / / for the lookup . <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions ; <nl> if ( isa < AbstractFunctionDecl > ( DC ) ) <nl> lookupOptions | = NameLookupFlags : : KnownPrivate ; <nl> - if ( shouldConsiderOuterResultsFor ( Name ) ) <nl> - lookupOptions | = NameLookupFlags : : IncludeOuterResults ; <nl> + <nl> + / / TODO : Include all of the possible members to give a solver a <nl> + / / chance to diagnose name shadowing which requires explicit <nl> + / / name / module qualifier to access top - level name . <nl> + lookupOptions | = NameLookupFlags : : IncludeOuterResults ; <nl> <nl> auto Lookup = TypeChecker : : lookupUnqualified ( DC , Name , Loc , lookupOptions ) ; <nl> <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> / / better matching candidates . <nl> if ( localDeclAfterUse ) { <nl> auto innerDecl = localDeclAfterUse ; <nl> - <nl> - / / Perform a thorough lookup if outer results was not included before . <nl> - if ( ! lookupOptions . contains ( NameLookupFlags : : IncludeOuterResults ) ) { <nl> - auto option = lookupOptions ; <nl> - option | = NameLookupFlags : : IncludeOuterResults ; <nl> - Lookup = lookupUnqualified ( DC , Name , Loc , option ) ; <nl> - } <nl> - <nl> while ( localDeclAfterUse ) { <nl> if ( Lookup . outerResults ( ) . empty ( ) ) { <nl> Context . Diags . diagnose ( Loc , diag : : use_local_before_declaration , Name ) ; <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> findNonMembers ( Lookup . innerResults ( ) , UDRE - > getRefKind ( ) , <nl> / * breakOnMember = * / true , ResultValues , isValid ) ; <nl> } <nl> - <nl> - / / Drop outer results if they are not supposed to be included . <nl> - if ( ! lookupOptions . contains ( NameLookupFlags : : IncludeOuterResults ) ) { <nl> - Lookup . filter ( [ & ] ( LookupResultEntry Result , bool isOuter ) { <nl> - return ! isOuter ; <nl> - } ) ; <nl> - } <nl> } <nl> <nl> / / If we have an unambiguous reference to a type decl , form a TypeExpr . <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> <nl> ResultValues . clear ( ) ; <nl> bool AllMemberRefs = true ; <nl> - bool AllConditionalConformances = true ; <nl> ValueDecl * Base = nullptr ; <nl> DeclContext * BaseDC = nullptr ; <nl> for ( auto Result : Lookup ) { <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> <nl> Base = ThisBase ; <nl> BaseDC = Result . getDeclContext ( ) ; <nl> - <nl> - / / Check if this result is derived through a conditional conformance , <nl> - / / meaning it comes from a protocol ( or extension ) where there ' s a <nl> - / / conditional conformance for the type with the method in question <nl> - / / ( NB . that type may not be the type associated with DC , for tested types <nl> - / / with static methods ) . <nl> - if ( auto Proto = Value - > getDeclContext ( ) - > getSelfProtocolDecl ( ) ) { <nl> - auto contextSelfType = <nl> - BaseDC - > getInnermostTypeContext ( ) - > getDeclaredInterfaceType ( ) ; <nl> - auto conformance = conformsToProtocol ( <nl> - contextSelfType , Proto , DC , <nl> - ConformanceCheckFlags : : InExpression | <nl> - ConformanceCheckFlags : : SkipConditionalRequirements ) ; <nl> - <nl> - if ( conformance . isInvalid ( ) | | <nl> - conformance . getConditionalRequirements ( ) . empty ( ) ) { <nl> - AllConditionalConformances = false ; <nl> - } <nl> - } <nl> - <nl> continue ; <nl> } <nl> <nl> Expr * TypeChecker : : resolveDeclRefExpr ( UnresolvedDeclRefExpr * UDRE , <nl> / * Implicit = * / true ) ; <nl> } <nl> <nl> - / / We * might * include any non - members that we found in outer contexts in <nl> - / / some special cases , for backwards compatibility : first , we have to be <nl> - / / looking for one of the special names <nl> - / / ( ' shouldConsiderOuterResultsFor ( Name ) ' ) , and second , all of the inner <nl> - / / results need to come from conditional conformances . The second condition <nl> - / / is how the problem here was encountered : a type ( ' Range ' ) was made to <nl> - / / conditionally conform to a new protocol ( ' Sequence ' ) , which introduced <nl> - / / some extra methods ( ' min ' and ' max ' ) that shadowed global functions that <nl> - / / people regularly called within extensions to that type ( usually adding <nl> - / / ' clamp ' ) . <nl> llvm : : SmallVector < ValueDecl * , 4 > outerAlternatives ; <nl> - if ( AllConditionalConformances ) { <nl> - ( void ) findNonMembers ( Lookup . outerResults ( ) , UDRE - > getRefKind ( ) , <nl> - / * breakOnMember = * / false , outerAlternatives , <nl> - / * isValid = * / [ & ] ( ValueDecl * ) { return true ; } ) ; <nl> - } <nl> + ( void ) findNonMembers ( Lookup . outerResults ( ) , UDRE - > getRefKind ( ) , <nl> + / * breakOnMember = * / false , outerAlternatives , <nl> + / * isValid = * / [ ] ( ValueDecl * choice ) - > bool { <nl> + return ! choice - > isInvalid ( ) ; <nl> + } ) ; <nl> <nl> / / Otherwise , form an UnresolvedDotExpr and sema will resolve it based on <nl> / / type information . <nl> mmm a / lib / Sema / TypeCheckNameLookup . cpp <nl> ppp b / lib / Sema / TypeCheckNameLookup . cpp <nl> namespace { <nl> addResult ( found ) ; <nl> return ; <nl> } <nl> + } else if ( isa < NominalTypeDecl > ( found ) ) { <nl> + / / Declaring nested types inside other types is currently <nl> + / / not supported by lookup would still return such members <nl> + / / so we have to account for that here as well . <nl> + addResult ( found ) ; <nl> + return ; <nl> } <nl> <nl> / / FIXME : the " isa < ProtocolDecl > ( ) " check will be wrong for <nl> mmm a / lib / Serialization / Deserialization . cpp <nl> ppp b / lib / Serialization / Deserialization . cpp <nl> class DeclDeserializer { <nl> uint8_t rawIntroducer ; <nl> bool isGetterMutating , isSetterMutating ; <nl> bool isLazyStorageProperty ; <nl> + bool isTopLevelGlobal ; <nl> DeclID lazyStorageID ; <nl> unsigned numAccessors , numBackingProperties ; <nl> uint8_t readImpl , writeImpl , readWriteImpl , opaqueReadOwnership ; <nl> class DeclDeserializer { <nl> hasNonPatternBindingInit , <nl> isGetterMutating , isSetterMutating , <nl> isLazyStorageProperty , <nl> + isTopLevelGlobal , <nl> lazyStorageID , <nl> opaqueReadOwnership , <nl> readImpl , writeImpl , readWriteImpl , <nl> class DeclDeserializer { <nl> } <nl> <nl> var - > setLazyStorageProperty ( isLazyStorageProperty ) ; <nl> + var - > setTopLevelGlobal ( isTopLevelGlobal ) ; <nl> <nl> / / If there are any backing properties , record them . <nl> if ( numBackingProperties > 0 ) { <nl> mmm a / lib / Serialization / ModuleFormat . h <nl> ppp b / lib / Serialization / ModuleFormat . h <nl> namespace decls_block { <nl> BCFixed < 1 > , / / is getter mutating ? <nl> BCFixed < 1 > , / / is setter mutating ? <nl> BCFixed < 1 > , / / is this the backing storage for a lazy property ? <nl> + BCFixed < 1 > , / / top level global ? <nl> DeclIDField , / / if this is a lazy property , this is the backing storage <nl> OpaqueReadOwnershipField , / / opaque read ownership <nl> ReadImplKindField , / / read implementation <nl> mmm a / lib / Serialization / Serialization . cpp <nl> ppp b / lib / Serialization / Serialization . cpp <nl> class Serializer : : DeclSerializer : public DeclVisitor < DeclSerializer > { <nl> var - > isGetterMutating ( ) , <nl> var - > isSetterMutating ( ) , <nl> var - > isLazyStorageProperty ( ) , <nl> + var - > isTopLevelGlobal ( ) , <nl> S . addDeclRef ( lazyStorage ) , <nl> accessors . OpaqueReadOwnership , <nl> accessors . ReadImpl , <nl> mmm a / test / APINotes / versioned - objc . swift <nl> ppp b / test / APINotes / versioned - objc . swift <nl> extension PrintingInterference { <nl> func testDroppingRenamedPrints ( ) { <nl> / / CHECK - DIAGS - 4 : [ [ @ LINE + 1 ] ] : { { [ 0 - 9 ] + } } : warning : use of ' print ' treated as a reference to instance method <nl> print ( self ) <nl> - / / CHECK - DIAGS - 5 : [ [ @ LINE - 1 ] ] : { { [ 0 - 9 ] + } } : error : missing argument for parameter ' extra ' in call <nl> + / / CHECK - DIAGS - 5 : [ [ @ LINE - 1 ] ] : { { [ 0 - 9 ] + } } : error : use of ' print ' refers to instance method rather than global function ' print ( _ : separator : terminator : ) ' in module ' Swift ' <nl> <nl> / / CHECK - DIAGS - 4 - NOT : [ [ @ LINE + 1 ] ] : { { [ 0 - 9 ] + } } : <nl> print ( self , extra : self ) <nl> mmm a / test / Constraints / members . swift <nl> ppp b / test / Constraints / members . swift <nl> do { <nl> / / rdar : / / problem / 25341015 <nl> extension Sequence { <nl> func r25341015_1 ( ) - > Int { <nl> - return max ( 1 , 2 ) / / expected - error { { use of ' max ' refers to instance method ' max ( by : ) ' rather than global function ' max ' in module ' Swift ' } } expected - note { { use ' Swift . ' to reference the global function in module ' Swift ' } } <nl> + return max ( 1 , 2 ) / / expected - error { { use of ' max ' refers to instance method rather than global function ' max ' in module ' Swift ' } } expected - note { { use ' Swift . ' to reference the global function in module ' Swift ' } } <nl> } <nl> } <nl> <nl> func r25341015 ( ) { <nl> class Bar { <nl> func baz ( ) { } <nl> func qux ( ) { <nl> - baz ( 1 , 2 ) / / expected - error { { argument passed to call that takes no arguments } } <nl> + baz ( 1 , 2 ) / / expected - error { { use of ' baz ' refers to instance method rather than local function ' baz ' } } <nl> } <nl> } <nl> } <nl> func bar_32854314 ( ) - > Int { <nl> extension Array where Element = = Int { <nl> func foo ( ) { <nl> let _ = min ( foo_32854314 ( ) , bar_32854314 ( ) ) / / expected - note { { use ' Swift . ' to reference the global function in module ' Swift ' } } { { 13 - 13 = Swift . } } <nl> - / / expected - error @ - 1 { { use of ' min ' nearly matches global function ' min ' in module ' Swift ' rather than instance method ' min ( by : ) ' } } <nl> + / / expected - error @ - 1 { { use of ' min ' refers to instance method rather than global function ' min ' in module ' Swift ' } } <nl> } <nl> <nl> func foo ( _ x : Int , _ y : Double ) { <nl> let _ = min ( x , y ) / / expected - note { { use ' Swift . ' to reference the global function in module ' Swift ' } } { { 13 - 13 = Swift . } } <nl> - / / expected - error @ - 1 { { use of ' min ' nearly matches global function ' min ' in module ' Swift ' rather than instance method ' min ( by : ) ' } } <nl> + / / expected - error @ - 1 { { use of ' min ' refers to instance method rather than global function ' min ' in module ' Swift ' } } <nl> } <nl> <nl> func bar ( ) { <nl> let _ = min ( 1 . 0 , 2 ) / / expected - note { { use ' Swift . ' to reference the global function in module ' Swift ' } } { { 13 - 13 = Swift . } } <nl> - / / expected - error @ - 1 { { use of ' min ' nearly matches global function ' min ' in module ' Swift ' rather than instance method ' min ( by : ) ' } } <nl> + / / expected - error @ - 1 { { use of ' min ' refers to instance method rather than global function ' min ' in module ' Swift ' } } <nl> } <nl> } <nl> <nl> mmm a / test / NameBinding / name_lookup_min_max_conditional_conformance . swift <nl> ppp b / test / NameBinding / name_lookup_min_max_conditional_conformance . swift <nl> extension ContainsMinMax { <nl> func min ( ) { } <nl> } <nl> <nl> - func foo ( _ : Int , _ : Int ) { } <nl> + func foo ( _ : Int , _ : Int ) { } / / expected - note 2 { { ' foo ' declared here } } <nl> <nl> protocol ContainsFoo { } <nl> extension ContainsFoo { <nl> extension NonConditional { <nl> / / expected - error @ - 1 { { use of ' min ' refers to instance method } } <nl> / / expected - note @ - 2 { { use ' Swift . ' to reference the global function } } <nl> <nl> - / / FIXME ( diagnostics ) : Better diagnostic in this case would be to suggest to add ` name_lookup_min_max_conditional_conformance . ` <nl> - / / to call because name ` foo ` is shadowed by instance method without arguments . Would be fixed by ` resolveDeclRefExpr ` refactoring . <nl> - _ = foo ( 5 , 6 ) / / expected - error { { argument passed to call that takes no arguments } } <nl> + _ = foo ( 5 , 6 ) / / expected - error { { use of ' foo ' refers to instance method rather than global function ' foo ' in module ' name_lookup_min_max_conditional_conformance ' } } <nl> + / / expected - note @ - 1 { { use ' name_lookup_min_max_conditional_conformance . ' to reference the global function in module ' name_lookup_min_max_conditional_conformance ' } } { { 13 - 13 = name_lookup_min_max_conditional_conformance . } } <nl> } <nl> } <nl> <nl> struct Conditional < T > { } <nl> extension Conditional : ContainsMinMax where T : ContainsMinMax { } <nl> - extension Conditional : ContainsFoo where T : ContainsFoo { } / / expected - note { { requirement from conditional conformance of ' Conditional < T > ' to ' ContainsFoo ' } } <nl> + extension Conditional : ContainsFoo where T : ContainsFoo { } <nl> <nl> extension Conditional { <nl> func f ( ) { <nl> extension Conditional { <nl> / / expected - warning @ - 1 { { use of ' min ' as reference to global function in module ' Swift ' will change in future versions of Swift to reference instance method in generic struct ' Conditional ' which comes via a conditional conformance } } <nl> / / expected - note @ - 2 { { use ' Swift . ' to continue to reference the global function } } <nl> <nl> - / / FIXME ( diagnostics ) : Same as line 39 , there should be only one error here about shadowing . <nl> _ = foo ( 5 , 6 ) <nl> - / / expected - error @ - 1 { { referencing instance method ' foo ( ) ' on ' Conditional ' requires that ' T ' conform to ' ContainsFoo ' } } <nl> - / / expected - error @ - 2 { { argument passed to call that takes no arguments } } <nl> + / / expected - error @ - 1 { { use of ' foo ' refers to instance method rather than global function ' foo ' in module ' name_lookup_min_max_conditional_conformance ' } } <nl> + / / expected - note @ - 2 { { use ' name_lookup_min_max_conditional_conformance . ' to reference the global function in module ' name_lookup_min_max_conditional_conformance ' } } { { 13 - 13 = name_lookup_min_max_conditional_conformance . } } <nl> } <nl> } <nl> mmm a / test / SILGen / without_actually_escaping . swift <nl> ppp b / test / SILGen / without_actually_escaping . swift <nl> func withoutActuallyEscapingConflict ( ) { <nl> modifyAndPerform ( & localVar , closure : $ 0 ) <nl> } <nl> } <nl> + <nl> + / / CHECK - LABEL : sil [ ossa ] @ $ s25without_actually_escaping0A25ActuallyEscapingCFunction8functionyyyXC_tF <nl> + / / CHECK : bb0 ( [ [ ARG : % . * ] ] : $ @ convention ( c ) @ noescape ( ) - > ( ) ) : <nl> + / / CHECK : [ [ E : % . * ] ] = convert_function [ [ ARG ] ] : $ @ convention ( c ) @ noescape ( ) - > ( ) to [ without_actually_escaping ] $ @ convention ( c ) ( ) - > ( ) <nl> + / / CHECK : [ [ F : % . * ] ] = function_ref @ $ s25without_actually_escaping0A25ActuallyEscapingCFunction8functionyyyXC_tFyyyXCXEfU_ : $ @ convention ( thin ) ( @ convention ( c ) ( ) - > ( ) ) - > ( ) <nl> + / / CHECK : apply [ [ F ] ] ( [ [ E ] ] ) : $ @ convention ( thin ) ( @ convention ( c ) ( ) - > ( ) ) - > ( ) <nl> + public func withoutActuallyEscapingCFunction ( function : ( @ convention ( c ) ( ) - > Void ) ) { <nl> + withoutActuallyEscaping ( function ) { f in <nl> + var pointer : UnsafeRawPointer ? = nil <nl> + pointer = unsafeBitCast ( f , to : UnsafeRawPointer . self ) <nl> + print ( pointer ) <nl> + } <nl> + } <nl> mmm a / test / Sema / circular_decl_checking . swift <nl> ppp b / test / Sema / circular_decl_checking . swift <nl> class HasGenericFunc { <nl> } <nl> } <nl> <nl> - class HasProp { <nl> + class HasProp { / / expected - note { { ' HasProp ' declared here } } <nl> var HasProp : HasProp { <nl> - return HasProp ( ) / / expected - error { { cannot call value of non - function type ' HasProp ' } } { { 19 - 21 = } } <nl> + return HasProp ( ) / / expected - error { { use of ' HasProp ' refers to instance method rather than class ' HasProp ' in module ' circular_decl_checking ' } } <nl> + / / expected - note @ - 1 { { use ' circular_decl_checking . ' to reference the class in module ' circular_decl_checking ' } } { { 12 - 12 = circular_decl_checking . } } <nl> } <nl> var SomethingElse : SomethingElse ? { / / expected - error { { use of undeclared type ' SomethingElse ' } } <nl> return nil <nl> mmm a / test / Serialization / Recovery / typedefs . swift <nl> ppp b / test / Serialization / Recovery / typedefs . swift <nl> import Lib <nl> / / CHECK - SIL - LABEL : sil hidden [ ossa ] @ $ s8typedefs11testSymbolsyyF <nl> func testSymbols ( ) { <nl> / / Check that the symbols are not using ' Bool ' . <nl> - / / CHECK - SIL : function_ref @ $ s3Lib1xs5Int32Vvau <nl> + / / CHECK - SIL : global_addr @ $ s3Lib9usesAssocs5Int32VSgvp <nl> _ = Lib . x <nl> - / / CHECK - SIL : function_ref @ $ s3Lib9usesAssocs5Int32VSgvau <nl> + / / CHECK - SIL : global_addr @ $ s3Lib1xs5Int32Vvp <nl> _ = Lib . usesAssoc <nl> } / / CHECK - SIL : end sil function ' $ s8typedefs11testSymbolsyyF ' <nl> <nl> mmm a / test / decl / nested / protocol . swift <nl> ppp b / test / decl / nested / protocol . swift <nl> class OuterGenericClass < T > { <nl> } <nl> } <nl> <nl> - protocol OuterProtocol { / / expected - note { { ' OuterProtocol ' declared here } } <nl> + protocol OuterProtocol { <nl> associatedtype Hen <nl> protocol InnerProtocol { / / expected - error { { protocol ' InnerProtocol ' cannot be nested inside another declaration } } <nl> associatedtype Rooster <nl> struct ConformsToOuterProtocol : OuterProtocol { <nl> typealias Hen = Int <nl> <nl> func f ( ) { let _ = InnerProtocol . self } <nl> - / / expected - error @ - 1 { { use of unresolved identifier ' InnerProtocol ' } } <nl> + / / expected - error @ - 1 { { protocol ' InnerProtocol ' can only be used as a generic constraint because it has Self or associated type requirements } } <nl> } <nl> <nl> protocol Racoon { <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | 1e6d56f11790a9756af12acf6e11090d485c2cd3 | 2020-01-31T18:59:08Z |
mmm a / src / mongo / base / status . cpp <nl> ppp b / src / mongo / base / status . cpp <nl> Status : : Status ( ErrorCodes : : Error code , StringData reason ) : Status ( code , reason . <nl> Status : : Status ( ErrorCodes : : Error code , const mongoutils : : str : : stream & reason ) <nl> : Status ( code , std : : string ( reason ) ) { } <nl> <nl> + Status Status : : withContext ( StringData reasonPrefix ) const { <nl> + return isOK ( ) ? Status : : OK ( ) : Status ( code ( ) , reasonPrefix + causedBy ( reason ( ) ) ) ; <nl> + } <nl> + <nl> std : : ostream & operator < < ( std : : ostream & os , const Status & status ) { <nl> return os < < status . codeString ( ) < < " " < < status . reason ( ) ; <nl> } <nl> mmm a / src / mongo / base / status . h <nl> ppp b / src / mongo / base / status . h <nl> class MONGO_WARN_UNUSED_RESULT_CLASS Status { <nl> * <nl> * For OK Statuses prefer using Status : : OK ( ) . If code is OK , the remaining arguments are <nl> * ignored . <nl> + * <nl> + * For adding context to the reason string , use withContext / addContext rather than making a new <nl> + * Status manually . <nl> * / <nl> MONGO_COMPILER_COLD_FUNCTION Status ( ErrorCodes : : Error code , std : : string reason ) ; <nl> MONGO_COMPILER_COLD_FUNCTION Status ( ErrorCodes : : Error code , const char * reason ) ; <nl> class MONGO_WARN_UNUSED_RESULT_CLASS Status { <nl> <nl> inline ~ Status ( ) ; <nl> <nl> + / * * <nl> + * Returns a new Status with the same data as this , but with the reason string prefixed with <nl> + * reasonPrefix and our standard " : : caused by : : " separator . The new reason is not visible to <nl> + * any other Statuses that share the same ErrorInfo object . <nl> + * <nl> + * No - op when called on an OK status . <nl> + * / <nl> + Status withContext ( StringData reasonPrefix ) const ; <nl> + void addContext ( StringData reasonPrefix ) { <nl> + * this = this - > withContext ( reasonPrefix ) ; <nl> + } <nl> + <nl> / * * <nl> * Only compares codes . Ignores reason strings . <nl> * / <nl> mmm a / src / mongo / base / status_test . cpp <nl> ppp b / src / mongo / base / status_test . cpp <nl> TEST ( Basic , Compare ) { <nl> ASSERT_NE ( errMax , Status : : OK ( ) ) ; <nl> } <nl> <nl> + TEST ( Basic , WithContext ) { <nl> + const Status orig ( ErrorCodes : : MaxError , " error " ) ; <nl> + <nl> + const auto copy = orig . withContext ( " context " ) ; <nl> + ASSERT_EQ ( copy . code ( ) , ErrorCodes : : MaxError ) ; <nl> + ASSERT ( str : : startsWith ( copy . reason ( ) , " context " ) ) < < copy . reason ( ) ; <nl> + ASSERT ( str : : endsWith ( copy . reason ( ) , " error " ) ) < < copy . reason ( ) ; <nl> + <nl> + ASSERT_EQ ( orig . code ( ) , ErrorCodes : : MaxError ) ; <nl> + ASSERT_EQ ( orig . reason ( ) , " error " ) ; <nl> + } <nl> + <nl> TEST ( Cloning , Copy ) { <nl> Status orig ( ErrorCodes : : MaxError , " error " ) ; <nl> ASSERT_EQUALS ( orig . refCount ( ) , 1U ) ; <nl> mmm a / src / mongo / client / dbclient_rs . cpp <nl> ppp b / src / mongo / client / dbclient_rs . cpp <nl> unique_ptr < DBClientCursor > DBClientReplicaSet : : query ( const string & ns , <nl> <nl> return checkSlaveQueryResult ( std : : move ( cursor ) ) ; <nl> } catch ( const DBException & ex ) { <nl> - const Status status = ex . toStatus ( ) ; <nl> - lastNodeErrMsg = str : : stream ( ) < < " can ' t query replica set node " <nl> - < < _lastSlaveOkHost < < " : " < < status . reason ( ) ; <nl> - _invalidateLastSlaveOkCache ( { status . code ( ) , lastNodeErrMsg } ) ; <nl> + const Status status = ex . toStatus ( str : : stream ( ) < < " can ' t query replica set node " <nl> + < < _lastSlaveOkHost ) ; <nl> + lastNodeErrMsg = status . reason ( ) ; <nl> + _invalidateLastSlaveOkCache ( status ) ; <nl> } <nl> } <nl> <nl> BSONObj DBClientReplicaSet : : findOne ( const string & ns , <nl> <nl> return conn - > findOne ( ns , query , fieldsToReturn , queryOptions ) ; <nl> } catch ( const DBException & ex ) { <nl> - const Status status = ex . toStatus ( ) ; <nl> - lastNodeErrMsg = str : : stream ( ) < < " can ' t findone replica set node " <nl> - < < _lastSlaveOkHost . toString ( ) < < " : " <nl> - < < status . reason ( ) ; <nl> - _invalidateLastSlaveOkCache ( { status . code ( ) , lastNodeErrMsg } ) ; <nl> + const Status status = ex . toStatus ( str : : stream ( ) < < " can ' t findone replica set node " <nl> + < < _lastSlaveOkHost . toString ( ) ) ; <nl> + lastNodeErrMsg = status . reason ( ) ; <nl> + _invalidateLastSlaveOkCache ( status ) ; <nl> } <nl> } <nl> <nl> void DBClientReplicaSet : : say ( Message & toSend , bool isRetry , string * actualServer <nl> _lazyState . _secondaryQueryOk = true ; <nl> _lazyState . _lastClient = conn ; <nl> } catch ( const DBException & ex ) { <nl> - const Status status = ex . toStatus ( ) ; <nl> - lastNodeErrMsg = str : : stream ( ) < < " can ' t callLazy replica set node " <nl> - < < _lastSlaveOkHost . toString ( ) < < " : " <nl> - < < status . reason ( ) ; <nl> - _invalidateLastSlaveOkCache ( { status . code ( ) , lastNodeErrMsg } ) ; <nl> + const Status status = <nl> + ex . toStatus ( str : : stream ( ) < < " can ' t callLazy replica set node " <nl> + < < _lastSlaveOkHost . toString ( ) ) ; <nl> + lastNodeErrMsg = status . reason ( ) ; <nl> + _invalidateLastSlaveOkCache ( status ) ; <nl> <nl> continue ; <nl> } <nl> mmm a / src / mongo / db / repl / initial_syncer . cpp <nl> ppp b / src / mongo / db / repl / initial_syncer . cpp <nl> Status InitialSyncer : : _checkForShutdownAndConvertStatus_inlock ( const Status & sta <nl> return Status ( ErrorCodes : : CallbackCanceled , message + " : initial syncer is shutting down " ) ; <nl> } <nl> <nl> - if ( ! status . isOK ( ) ) { <nl> - return Status ( status . code ( ) , message + " : " + status . reason ( ) ) ; <nl> - } <nl> - <nl> - return Status : : OK ( ) ; <nl> + return status . withContext ( message ) ; <nl> } <nl> <nl> Status InitialSyncer : : _scheduleWorkAndSaveHandle_inlock ( <nl> mmm a / src / mongo / db / repl / initial_syncer_test . cpp <nl> ppp b / src / mongo / db / repl / initial_syncer_test . cpp <nl> TEST_F ( InitialSyncerTest , GetInitialSyncProgressReturnsCorrectProgress ) { <nl> ASSERT_EQUALS ( attempts . nFields ( ) , 1 ) < < attempts ; <nl> BSONObj attempt0 = attempts [ " 0 " ] . Obj ( ) ; <nl> ASSERT_EQUALS ( attempt0 . nFields ( ) , 3 ) < < attempt0 ; <nl> - ASSERT_EQUALS ( <nl> - attempt0 . getStringField ( " status " ) , <nl> - std : : string ( <nl> - " FailedToParse : error cloning databases : fail on clone - - listDBs injected failure " ) ) <nl> + ASSERT_EQUALS ( attempt0 . getStringField ( " status " ) , <nl> + std : : string ( " FailedToParse : error cloning databases : : caused by : : fail on " <nl> + " clone - - listDBs injected failure " ) ) <nl> < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 [ " durationMillis " ] . type ( ) , NumberInt ) < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 . getStringField ( " syncSource " ) , std : : string ( " localhost : 27017 " ) ) <nl> TEST_F ( InitialSyncerTest , GetInitialSyncProgressReturnsCorrectProgress ) { <nl> ASSERT_EQUALS ( attempts . nFields ( ) , 1 ) < < progress ; <nl> attempt0 = attempts [ " 0 " ] . Obj ( ) ; <nl> ASSERT_EQUALS ( attempt0 . nFields ( ) , 3 ) < < attempt0 ; <nl> - ASSERT_EQUALS ( <nl> - attempt0 . getStringField ( " status " ) , <nl> - std : : string ( <nl> - " FailedToParse : error cloning databases : fail on clone - - listDBs injected failure " ) ) <nl> + ASSERT_EQUALS ( attempt0 . getStringField ( " status " ) , <nl> + std : : string ( " FailedToParse : error cloning databases : : caused by : : fail on " <nl> + " clone - - listDBs injected failure " ) ) <nl> < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 [ " durationMillis " ] . type ( ) , NumberInt ) < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 . getStringField ( " syncSource " ) , std : : string ( " localhost : 27017 " ) ) <nl> TEST_F ( InitialSyncerTest , GetInitialSyncProgressReturnsCorrectProgress ) { <nl> <nl> attempt0 = attempts [ " 0 " ] . Obj ( ) ; <nl> ASSERT_EQUALS ( attempt0 . nFields ( ) , 3 ) < < attempt0 ; <nl> - ASSERT_EQUALS ( <nl> - attempt0 . getStringField ( " status " ) , <nl> - std : : string ( <nl> - " FailedToParse : error cloning databases : fail on clone - - listDBs injected failure " ) ) <nl> + ASSERT_EQUALS ( attempt0 . getStringField ( " status " ) , <nl> + std : : string ( " FailedToParse : error cloning databases : : caused by : : fail on " <nl> + " clone - - listDBs injected failure " ) ) <nl> < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 [ " durationMillis " ] . type ( ) , NumberInt ) < < attempt0 ; <nl> ASSERT_EQUALS ( attempt0 . getStringField ( " syncSource " ) , std : : string ( " localhost : 27017 " ) ) <nl> mmm a / src / mongo / db / repl / rollback_impl . cpp <nl> ppp b / src / mongo / db / repl / rollback_impl . cpp <nl> Status RollbackImpl : : _transitionToRollback ( OperationContext * opCtx ) { <nl> <nl> auto status = _replicationCoordinator - > setFollowerMode ( MemberState : : RS_ROLLBACK ) ; <nl> if ( ! status . isOK ( ) ) { <nl> - std : : string msg = str : : stream ( ) <nl> - < < " Cannot transition from " < < _replicationCoordinator - > getMemberState ( ) . toString ( ) <nl> - < < " to " < < MemberState ( MemberState : : RS_ROLLBACK ) . toString ( ) <nl> - < < causedBy ( status . reason ( ) ) ; <nl> - log ( ) < < msg ; <nl> - return Status ( status . code ( ) , msg ) ; <nl> + status . addContext ( str : : stream ( ) < < " Cannot transition from " <nl> + < < _replicationCoordinator - > getMemberState ( ) . toString ( ) <nl> + < < " to " <nl> + < < MemberState ( MemberState : : RS_ROLLBACK ) . toString ( ) ) ; <nl> + log ( ) < < status ; <nl> + return status ; <nl> } <nl> } <nl> return Status : : OK ( ) ; <nl> mmm a / src / mongo / s / catalog / sharding_catalog_client_impl . cpp <nl> ppp b / src / mongo / s / catalog / sharding_catalog_client_impl . cpp <nl> Status ShardingCatalogClientImpl : : applyChunkOpsDeprecated ( OperationContext * opCt <nl> < < " . Result : " < < response . getValue ( ) . response ; <nl> } <nl> <nl> - return Status ( status . code ( ) , errMsg ) ; <nl> + return status . withContext ( errMsg ) ; <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> mmm a / src / mongo / util / assert_util . h <nl> ppp b / src / mongo / util / assert_util . h <nl> class DBException : public std : : exception { <nl> return reason ( ) . c_str ( ) ; <nl> } <nl> <nl> - virtual void addContext ( const std : : string & str ) { <nl> - _status = Status ( code ( ) , str + causedBy ( reason ( ) ) ) ; <nl> + virtual void addContext ( StringData context ) { <nl> + _status . addContext ( context ) ; <nl> } <nl> <nl> - Status toStatus ( const std : : string & context ) const { <nl> - return Status ( code ( ) , context + causedBy ( * this ) ) ; <nl> + Status toStatus ( StringData context ) const { <nl> + return _status . withContext ( context ) ; <nl> } <nl> const Status & toStatus ( ) const { <nl> return _status ; <nl> | SERVER - 31734 Add Status : : withContext ( ) and addContext ( ) | mongodb/mongo | 51ebfe7bb870a1665653ad8088b121706ce3d5b5 | 2017-11-02T18:25:22Z |
mmm a / src / SConscript <nl> ppp b / src / SConscript <nl> SOURCES = { <nl> ' codegen . cc ' , ' compilation - cache . cc ' , ' compiler . cc ' , ' contexts . cc ' , <nl> ' conversions . cc ' , ' counters . cc ' , ' dateparser . cc ' , ' debug . cc ' , <nl> ' debug - agent . cc ' , ' disassembler . cc ' , ' execution . cc ' , ' factory . cc ' , <nl> - ' flags . cc ' , ' frame - element . cc ' , ' frames . cc ' , ' func - name - inferrer . cc ' , <nl> - ' global - handles . cc ' , ' handles . cc ' , ' hashmap . cc ' , ' heap . cc ' , <nl> - ' heap - profiler . cc ' , ' ic . cc ' , ' interpreter - irregexp . cc ' , ' jsregexp . cc ' , <nl> - ' jump - target . cc ' , ' log . cc ' , ' log - utils . cc ' , ' mark - compact . cc ' , <nl> - ' messages . cc ' , ' objects . cc ' , ' oprofile - agent . cc ' , ' parser . cc ' , <nl> - ' property . cc ' , ' regexp - macro - assembler . cc ' , <nl> - ' regexp - macro - assembler - irregexp . cc ' , ' regexp - stack . cc ' , <nl> - ' register - allocator . cc ' , ' rewriter . cc ' , ' runtime . cc ' , ' scanner . cc ' , <nl> - ' scopeinfo . cc ' , ' scopes . cc ' , ' serialize . cc ' , ' snapshot - common . cc ' , <nl> - ' spaces . cc ' , ' string - stream . cc ' , ' stub - cache . cc ' , ' token . cc ' , ' top . cc ' , <nl> - ' unicode . cc ' , ' usage - analyzer . cc ' , ' utils . cc ' , ' v8 - counters . cc ' , <nl> - ' v8 . cc ' , ' v8threads . cc ' , ' variables . cc ' , ' version . cc ' , <nl> + ' flags . cc ' , ' frame - element . cc ' , ' frames . cc ' , <nl> + ' func - name - inferrer . cc ' , ' global - handles . cc ' , ' handles . cc ' , <nl> + ' hashmap . cc ' , ' heap . cc ' , ' heap - profiler . cc ' , ' ic . cc ' , <nl> + ' interpreter - irregexp . cc ' , ' jsregexp . cc ' , ' jump - target . cc ' , ' log . cc ' , <nl> + ' log - utils . cc ' , ' mark - compact . cc ' , ' messages . cc ' , ' objects . cc ' , <nl> + ' oprofile - agent . cc ' , ' parser . cc ' , ' property . cc ' , <nl> + ' regexp - macro - assembler . cc ' , ' regexp - macro - assembler - irregexp . cc ' , <nl> + ' regexp - stack . cc ' , ' register - allocator . cc ' , ' rewriter . cc ' , ' runtime . cc ' , <nl> + ' scanner . cc ' , ' scopeinfo . cc ' , ' scopes . cc ' , ' serialize . cc ' , <nl> + ' snapshot - common . cc ' , ' spaces . cc ' , ' string - stream . cc ' , ' stub - cache . cc ' , <nl> + ' token . cc ' , ' top . cc ' , ' unicode . cc ' , ' usage - analyzer . cc ' , ' utils . cc ' , <nl> + ' v8 - counters . cc ' , ' v8 . cc ' , ' v8threads . cc ' , ' variables . cc ' , ' version . cc ' , <nl> ' virtual - frame . cc ' , ' zone . cc ' <nl> ] , <nl> ' arch : arm ' : [ <nl> SOURCES = { <nl> ' arm / stub - cache - arm . cc ' , ' arm / virtual - frame - arm . cc ' <nl> ] , <nl> ' arch : ia32 ' : [ <nl> - ' ia32 / assembler - ia32 . cc ' , ' ia32 / builtins - ia32 . cc ' , <nl> + ' fast - codegen . cc ' , ' ia32 / assembler - ia32 . cc ' , ' ia32 / builtins - ia32 . cc ' , <nl> ' ia32 / codegen - ia32 . cc ' , ' ia32 / cpu - ia32 . cc ' , ' ia32 / disasm - ia32 . cc ' , <nl> - ' ia32 / debug - ia32 . cc ' , ' ia32 / frames - ia32 . cc ' , ' ia32 / ic - ia32 . cc ' , <nl> - ' ia32 / jump - target - ia32 . cc ' , ' ia32 / macro - assembler - ia32 . cc ' , <nl> - ' ia32 / regexp - macro - assembler - ia32 . cc ' , <nl> + ' ia32 / debug - ia32 . cc ' , ' ia32 / fast - codegen - ia32 . cc ' , <nl> + ' ia32 / frames - ia32 . cc ' , ' ia32 / ic - ia32 . cc ' , ' ia32 / jump - target - ia32 . cc ' , <nl> + ' ia32 / macro - assembler - ia32 . cc ' , ' ia32 / regexp - macro - assembler - ia32 . cc ' , <nl> ' ia32 / register - allocator - ia32 . cc ' , ' ia32 / stub - cache - ia32 . cc ' , <nl> ' ia32 / virtual - frame - ia32 . cc ' <nl> ] , <nl> mmm a / src / arm / codegen - arm . h <nl> ppp b / src / arm / codegen - arm . h <nl> class CodeGenerator : public AstVisitor { <nl> Handle < Script > script , <nl> bool is_eval ) ; <nl> <nl> + / / Printing of AST , etc . as requested by flags . <nl> + static void MakeCodePrologue ( FunctionLiteral * fun ) ; <nl> + <nl> + / / Allocate and install the code . <nl> + static Handle < Code > MakeCodeEpilogue ( FunctionLiteral * fun , <nl> + MacroAssembler * masm , <nl> + Code : : Flags flags , <nl> + Handle < Script > script ) ; <nl> + <nl> # ifdef ENABLE_LOGGING_AND_PROFILING <nl> static bool ShouldGenerateLog ( Expression * type ) ; <nl> # endif <nl> mmm a / src / codegen . cc <nl> ppp b / src / codegen . cc <nl> void CodeGenerator : : DeleteFrame ( ) { <nl> } <nl> <nl> <nl> - / / Generate the code . Takes a function literal , generates code for it , assemble <nl> - / / all the pieces into a Code object . This function is only to be called by <nl> - / / the compiler . cc code . <nl> - Handle < Code > CodeGenerator : : MakeCode ( FunctionLiteral * flit , <nl> - Handle < Script > script , <nl> - bool is_eval ) { <nl> - # ifdef ENABLE_DISASSEMBLER <nl> - bool print_code = Bootstrapper : : IsActive ( ) <nl> - ? FLAG_print_builtin_code <nl> - : FLAG_print_code ; <nl> - # endif <nl> - <nl> + void CodeGenerator : : MakeCodePrologue ( FunctionLiteral * fun ) { <nl> # ifdef DEBUG <nl> bool print_source = false ; <nl> bool print_ast = false ; <nl> Handle < Code > CodeGenerator : : MakeCode ( FunctionLiteral * flit , <nl> <nl> if ( FLAG_trace_codegen | | print_source | | print_ast ) { <nl> PrintF ( " * * * Generate code for % s function : " , ftype ) ; <nl> - flit - > name ( ) - > ShortPrint ( ) ; <nl> + fun - > name ( ) - > ShortPrint ( ) ; <nl> PrintF ( " * * * \ n " ) ; <nl> } <nl> <nl> if ( print_source ) { <nl> - PrintF ( " mmm Source from AST mmm \ n % s \ n " , PrettyPrinter ( ) . PrintProgram ( flit ) ) ; <nl> + PrintF ( " mmm Source from AST mmm \ n % s \ n " , PrettyPrinter ( ) . PrintProgram ( fun ) ) ; <nl> } <nl> <nl> if ( print_ast ) { <nl> - PrintF ( " mmm AST mmm \ n % s \ n " , AstPrinter ( ) . PrintProgram ( flit ) ) ; <nl> + PrintF ( " mmm AST mmm \ n % s \ n " , AstPrinter ( ) . PrintProgram ( fun ) ) ; <nl> } <nl> <nl> if ( print_json_ast ) { <nl> JsonAstBuilder builder ; <nl> - PrintF ( " % s " , builder . BuildProgram ( flit ) ) ; <nl> + PrintF ( " % s " , builder . BuildProgram ( fun ) ) ; <nl> } <nl> # endif / / DEBUG <nl> + } <nl> <nl> - / / Generate code . <nl> - const int initial_buffer_size = 4 * KB ; <nl> - CodeGenerator cgen ( initial_buffer_size , script , is_eval ) ; <nl> - CodeGeneratorScope scope ( & cgen ) ; <nl> - cgen . GenCode ( flit ) ; <nl> - if ( cgen . HasStackOverflow ( ) ) { <nl> - ASSERT ( ! Top : : has_pending_exception ( ) ) ; <nl> - return Handle < Code > : : null ( ) ; <nl> - } <nl> <nl> - / / Allocate and install the code . Time the rest of this function as <nl> - / / code creation . <nl> - HistogramTimerScope timer ( & Counters : : code_creation ) ; <nl> + Handle < Code > CodeGenerator : : MakeCodeEpilogue ( FunctionLiteral * fun , <nl> + MacroAssembler * masm , <nl> + Code : : Flags flags , <nl> + Handle < Script > script ) { <nl> + / / Allocate and install the code . <nl> CodeDesc desc ; <nl> - cgen . masm ( ) - > GetCode ( & desc ) ; <nl> - ZoneScopeInfo sinfo ( flit - > scope ( ) ) ; <nl> - InLoopFlag in_loop = ( cgen . loop_nesting ( ) ! = 0 ) ? IN_LOOP : NOT_IN_LOOP ; <nl> - Code : : Flags flags = Code : : ComputeFlags ( Code : : FUNCTION , in_loop ) ; <nl> - Handle < Code > code = Factory : : NewCode ( desc , <nl> - & sinfo , <nl> - flags , <nl> - cgen . masm ( ) - > CodeObject ( ) ) ; <nl> + masm - > GetCode ( & desc ) ; <nl> + ZoneScopeInfo sinfo ( fun - > scope ( ) ) ; <nl> + Handle < Code > code = <nl> + Factory : : NewCode ( desc , & sinfo , flags , masm - > CodeObject ( ) ) ; <nl> <nl> / / Add unresolved entries in the code to the fixup list . <nl> - Bootstrapper : : AddFixup ( * code , cgen . masm ( ) ) ; <nl> + Bootstrapper : : AddFixup ( * code , masm ) ; <nl> <nl> # ifdef ENABLE_DISASSEMBLER <nl> + bool print_code = Bootstrapper : : IsActive ( ) <nl> + ? FLAG_print_builtin_code <nl> + : FLAG_print_code ; <nl> if ( print_code ) { <nl> / / Print the source code if available . <nl> if ( ! script - > IsUndefined ( ) & & ! script - > source ( ) - > IsUndefined ( ) ) { <nl> PrintF ( " mmm Raw source mmm \ n " ) ; <nl> StringInputBuffer stream ( String : : cast ( script - > source ( ) ) ) ; <nl> - stream . Seek ( flit - > start_position ( ) ) ; <nl> - / / flit - > end_position ( ) points to the last character in the stream . We <nl> + stream . Seek ( fun - > start_position ( ) ) ; <nl> + / / fun - > end_position ( ) points to the last character in the stream . We <nl> / / need to compensate by adding one to calculate the length . <nl> - int source_len = flit - > end_position ( ) - flit - > start_position ( ) + 1 ; <nl> + int source_len = fun - > end_position ( ) - fun - > start_position ( ) + 1 ; <nl> for ( int i = 0 ; i < source_len ; i + + ) { <nl> if ( stream . has_more ( ) ) PrintF ( " % c " , stream . GetNext ( ) ) ; <nl> } <nl> PrintF ( " \ n \ n " ) ; <nl> } <nl> PrintF ( " mmm Code mmm \ n " ) ; <nl> - code - > Disassemble ( * flit - > name ( ) - > ToCString ( ) ) ; <nl> + code - > Disassemble ( * fun - > name ( ) - > ToCString ( ) ) ; <nl> } <nl> # endif / / ENABLE_DISASSEMBLER <nl> <nl> if ( ! code . is_null ( ) ) { <nl> Counters : : total_compiled_code_size . Increment ( code - > instruction_size ( ) ) ; <nl> } <nl> - <nl> return code ; <nl> } <nl> <nl> <nl> + / / Generate the code . Takes a function literal , generates code for it , assemble <nl> + / / all the pieces into a Code object . This function is only to be called by <nl> + / / the compiler . cc code . <nl> + Handle < Code > CodeGenerator : : MakeCode ( FunctionLiteral * fun , <nl> + Handle < Script > script , <nl> + bool is_eval ) { <nl> + MakeCodePrologue ( fun ) ; <nl> + / / Generate code . <nl> + const int kInitialBufferSize = 4 * KB ; <nl> + CodeGenerator cgen ( kInitialBufferSize , script , is_eval ) ; <nl> + CodeGeneratorScope scope ( & cgen ) ; <nl> + cgen . GenCode ( fun ) ; <nl> + if ( cgen . HasStackOverflow ( ) ) { <nl> + ASSERT ( ! Top : : has_pending_exception ( ) ) ; <nl> + return Handle < Code > : : null ( ) ; <nl> + } <nl> + <nl> + InLoopFlag in_loop = ( cgen . loop_nesting ( ) ! = 0 ) ? IN_LOOP : NOT_IN_LOOP ; <nl> + Code : : Flags flags = Code : : ComputeFlags ( Code : : FUNCTION , in_loop ) ; <nl> + return MakeCodeEpilogue ( fun , cgen . masm ( ) , flags , script ) ; <nl> + } <nl> + <nl> + <nl> # ifdef ENABLE_LOGGING_AND_PROFILING <nl> <nl> bool CodeGenerator : : ShouldGenerateLog ( Expression * type ) { <nl> mmm a / src / codegen . h <nl> ppp b / src / codegen . h <nl> <nl> / / The contract to the shared code is that the the CodeGenerator is a subclass <nl> / / of Visitor and that the following methods are available publicly : <nl> / / MakeCode <nl> + / / MakeCodePrologue <nl> + / / MakeCodeEpilogue <nl> / / SetFunctionInfo <nl> / / masm <nl> / / frame <nl> mmm a / src / compiler . cc <nl> ppp b / src / compiler . cc <nl> <nl> # include " compilation - cache . h " <nl> # include " compiler . h " <nl> # include " debug . h " <nl> + # include " fast - codegen . h " <nl> # include " oprofile - agent . h " <nl> # include " rewriter . h " <nl> # include " scopes . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + # ifdef V8_TARGET_ARCH_IA32 <nl> + <nl> + class CodeGenSelector : public AstVisitor { <nl> + public : <nl> + enum CodeGenTag { NORMAL , FAST } ; <nl> + <nl> + CodeGenSelector ( ) : has_supported_syntax_ ( true ) { } <nl> + <nl> + CodeGenTag Select ( FunctionLiteral * fun ) ; <nl> + <nl> + private : <nl> + void VisitStatements ( ZoneList < Statement * > * stmts ) ; <nl> + <nl> + / / AST node visit functions . <nl> + # define DECLARE_VISIT ( type ) virtual void Visit # # type ( type * node ) ; <nl> + AST_NODE_LIST ( DECLARE_VISIT ) <nl> + # undef DECLARE_VISIT <nl> + <nl> + bool has_supported_syntax_ ; <nl> + <nl> + DISALLOW_COPY_AND_ASSIGN ( CodeGenSelector ) ; <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + <nl> static Handle < Code > MakeCode ( FunctionLiteral * literal , <nl> Handle < Script > script , <nl> Handle < Context > context , <nl> static Handle < Code > MakeCode ( FunctionLiteral * literal , <nl> } <nl> <nl> / / Generate code and return it . <nl> - Handle < Code > result = CodeGenerator : : MakeCode ( literal , script , is_eval ) ; <nl> - return result ; <nl> + # ifdef V8_TARGET_ARCH_IA32 <nl> + if ( FLAG_fast_compiler ) { <nl> + CodeGenSelector selector ; <nl> + CodeGenSelector : : CodeGenTag code_gen = selector . Select ( literal ) ; <nl> + if ( code_gen = = CodeGenSelector : : FAST ) { <nl> + return FastCodeGenerator : : MakeCode ( literal , script ) ; <nl> + } <nl> + ASSERT ( code_gen = = CodeGenSelector : : NORMAL ) ; <nl> + } <nl> + # endif <nl> + <nl> + return CodeGenerator : : MakeCode ( literal , script , is_eval ) ; <nl> } <nl> <nl> <nl> bool Compiler : : CompileLazy ( Handle < SharedFunctionInfo > shared , <nl> } <nl> <nl> <nl> + # ifdef V8_TARGET_ARCH_IA32 <nl> + <nl> + CodeGenSelector : : CodeGenTag CodeGenSelector : : Select ( FunctionLiteral * fun ) { <nl> + Scope * scope = fun - > scope ( ) ; <nl> + <nl> + if ( ! scope - > is_global_scope ( ) ) return NORMAL ; <nl> + ASSERT ( scope - > num_heap_slots ( ) = = 0 ) ; <nl> + ASSERT ( scope - > arguments ( ) = = NULL ) ; <nl> + <nl> + if ( ! scope - > declarations ( ) - > is_empty ( ) ) return NORMAL ; <nl> + if ( fun - > materialized_literal_count ( ) > 0 ) return NORMAL ; <nl> + if ( fun - > body ( ) - > is_empty ( ) ) return NORMAL ; <nl> + <nl> + has_supported_syntax_ = true ; <nl> + VisitStatements ( fun - > body ( ) ) ; <nl> + return has_supported_syntax_ ? FAST : NORMAL ; <nl> + } <nl> + <nl> + <nl> + # define BAILOUT ( reason ) \ <nl> + do { \ <nl> + if ( FLAG_trace_bailout ) { \ <nl> + PrintF ( " % s \ n " , reason ) ; \ <nl> + } \ <nl> + has_supported_syntax_ = false ; \ <nl> + return ; \ <nl> + } while ( false ) <nl> + <nl> + <nl> + # define CHECK_BAILOUT \ <nl> + do { \ <nl> + if ( ! has_supported_syntax_ ) return ; \ <nl> + } while ( false ) <nl> + <nl> + <nl> + void CodeGenSelector : : VisitStatements ( ZoneList < Statement * > * stmts ) { <nl> + for ( int i = 0 , len = stmts - > length ( ) ; i < len ; i + + ) { <nl> + CHECK_BAILOUT ; <nl> + Visit ( stmts - > at ( i ) ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitDeclaration ( Declaration * decl ) { <nl> + BAILOUT ( " Declaration " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitBlock ( Block * stmt ) { <nl> + BAILOUT ( " Block " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitExpressionStatement ( ExpressionStatement * stmt ) { <nl> + Visit ( stmt - > expression ( ) ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitEmptyStatement ( EmptyStatement * stmt ) { <nl> + BAILOUT ( " EmptyStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitIfStatement ( IfStatement * stmt ) { <nl> + BAILOUT ( " IfStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitContinueStatement ( ContinueStatement * stmt ) { <nl> + BAILOUT ( " ContinueStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitBreakStatement ( BreakStatement * stmt ) { <nl> + BAILOUT ( " BreakStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitReturnStatement ( ReturnStatement * stmt ) { <nl> + Visit ( stmt - > expression ( ) ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitWithEnterStatement ( WithEnterStatement * stmt ) { <nl> + BAILOUT ( " WithEnterStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitWithExitStatement ( WithExitStatement * stmt ) { <nl> + BAILOUT ( " WithExitStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitSwitchStatement ( SwitchStatement * stmt ) { <nl> + BAILOUT ( " SwitchStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitDoWhileStatement ( DoWhileStatement * stmt ) { <nl> + BAILOUT ( " DoWhileStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitWhileStatement ( WhileStatement * stmt ) { <nl> + BAILOUT ( " WhileStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitForStatement ( ForStatement * stmt ) { <nl> + BAILOUT ( " ForStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitForInStatement ( ForInStatement * stmt ) { <nl> + BAILOUT ( " ForInStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitTryCatchStatement ( TryCatchStatement * stmt ) { <nl> + BAILOUT ( " TryCatchStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitTryFinallyStatement ( TryFinallyStatement * stmt ) { <nl> + BAILOUT ( " TryFinallyStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitDebuggerStatement ( DebuggerStatement * stmt ) { <nl> + BAILOUT ( " DebuggerStatement " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitFunctionLiteral ( FunctionLiteral * expr ) { <nl> + BAILOUT ( " FunctionLiteral " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitFunctionBoilerplateLiteral ( <nl> + FunctionBoilerplateLiteral * expr ) { <nl> + BAILOUT ( " FunctionBoilerplateLiteral " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitConditional ( Conditional * expr ) { <nl> + BAILOUT ( " Conditional " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitSlot ( Slot * expr ) { <nl> + Slot : : Type type = expr - > type ( ) ; <nl> + if ( type ! = Slot : : PARAMETER & & type ! = Slot : : LOCAL ) { <nl> + BAILOUT ( " non - parameter / non - local slot reference " ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitVariableProxy ( VariableProxy * expr ) { <nl> + Expression * rewrite = expr - > var ( ) - > rewrite ( ) ; <nl> + if ( rewrite = = NULL ) BAILOUT ( " global variable reference " ) ; <nl> + Visit ( rewrite ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitLiteral ( Literal * expr ) { <nl> + / / All literals are supported . <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitRegExpLiteral ( RegExpLiteral * expr ) { <nl> + BAILOUT ( " RegExpLiteral " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitObjectLiteral ( ObjectLiteral * expr ) { <nl> + BAILOUT ( " ObjectLiteral " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitArrayLiteral ( ArrayLiteral * expr ) { <nl> + BAILOUT ( " ArrayLiteral " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCatchExtensionObject ( CatchExtensionObject * expr ) { <nl> + BAILOUT ( " CatchExtensionObject " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitAssignment ( Assignment * expr ) { <nl> + / / We support plain non - compound assignments to parameters and <nl> + / / non - context ( stack - allocated ) locals . <nl> + if ( expr - > starts_initialization_block ( ) ) BAILOUT ( " initialization block " ) ; <nl> + <nl> + Token : : Value op = expr - > op ( ) ; <nl> + if ( op = = Token : : INIT_CONST ) BAILOUT ( " initialize constant " ) ; <nl> + if ( op ! = Token : : ASSIGN & & op ! = Token : : INIT_VAR ) { <nl> + BAILOUT ( " compound assignment " ) ; <nl> + } <nl> + <nl> + Variable * var = expr - > target ( ) - > AsVariableProxy ( ) - > AsVariable ( ) ; <nl> + if ( var = = NULL | | var - > is_global ( ) ) BAILOUT ( " non - variable assignment " ) ; <nl> + <nl> + ASSERT ( var - > slot ( ) ! = NULL ) ; <nl> + Slot : : Type type = var - > slot ( ) - > type ( ) ; <nl> + if ( type ! = Slot : : PARAMETER & & type ! = Slot : : LOCAL ) { <nl> + BAILOUT ( " non - parameter / non - local slot assignment " ) ; <nl> + } <nl> + <nl> + Visit ( expr - > value ( ) ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitThrow ( Throw * expr ) { <nl> + BAILOUT ( " Throw " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitProperty ( Property * expr ) { <nl> + BAILOUT ( " Property " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCall ( Call * expr ) { <nl> + BAILOUT ( " Call " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCallNew ( CallNew * expr ) { <nl> + BAILOUT ( " CallNew " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCallRuntime ( CallRuntime * expr ) { <nl> + BAILOUT ( " CallRuntime " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitUnaryOperation ( UnaryOperation * expr ) { <nl> + BAILOUT ( " UnaryOperation " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCountOperation ( CountOperation * expr ) { <nl> + BAILOUT ( " CountOperation " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitBinaryOperation ( BinaryOperation * expr ) { <nl> + BAILOUT ( " BinaryOperation " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitCompareOperation ( CompareOperation * expr ) { <nl> + BAILOUT ( " CompareOperation " ) ; <nl> + } <nl> + <nl> + <nl> + void CodeGenSelector : : VisitThisFunction ( ThisFunction * expr ) { <nl> + BAILOUT ( " ThisFunction " ) ; <nl> + } <nl> + <nl> + # undef BAILOUT <nl> + # undef CHECK_BAILOUT <nl> + <nl> + # endif / / V8_TARGET_ARCH_IA32 <nl> + <nl> + <nl> } } / / namespace v8 : : internal <nl> new file mode 100644 <nl> index 00000000000 . . 97404e00649 <nl> mmm / dev / null <nl> ppp b / src / fast - codegen . cc <nl> <nl> + / / Copyright 2009 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # include " v8 . h " <nl> + <nl> + # include " codegen - inl . h " <nl> + # include " fast - codegen . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + Handle < Code > FastCodeGenerator : : MakeCode ( FunctionLiteral * fun , <nl> + Handle < Script > script ) { <nl> + CodeGenerator : : MakeCodePrologue ( fun ) ; <nl> + const int kInitialBufferSize = 4 * KB ; <nl> + MacroAssembler masm ( NULL , kInitialBufferSize ) ; <nl> + FastCodeGenerator cgen ( & masm ) ; <nl> + cgen . Generate ( fun ) ; <nl> + if ( cgen . HasStackOverflow ( ) ) { <nl> + ASSERT ( ! Top : : has_pending_exception ( ) ) ; <nl> + return Handle < Code > : : null ( ) ; <nl> + } <nl> + Code : : Flags flags = Code : : ComputeFlags ( Code : : FUNCTION , NOT_IN_LOOP ) ; <nl> + return CodeGenerator : : MakeCodeEpilogue ( fun , & masm , flags , script ) ; <nl> + } <nl> + <nl> + <nl> + int FastCodeGenerator : : SlotOffset ( Slot * slot ) { <nl> + / / Offset is negative because higher indexes are at lower addresses . <nl> + int offset = - slot - > index ( ) * kPointerSize ; <nl> + / / Adjust by a ( parameter or local ) base offset . <nl> + switch ( slot - > type ( ) ) { <nl> + case Slot : : PARAMETER : <nl> + offset + = ( function_ - > scope ( ) - > num_parameters ( ) + 1 ) * kPointerSize ; <nl> + break ; <nl> + case Slot : : LOCAL : <nl> + offset + = JavaScriptFrameConstants : : kLocal0Offset ; <nl> + break ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + return offset ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitDeclaration ( Declaration * decl ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitBlock ( Block * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitEmptyStatement ( EmptyStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitIfStatement ( IfStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitContinueStatement ( ContinueStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitBreakStatement ( BreakStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitWithEnterStatement ( WithEnterStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitWithExitStatement ( WithExitStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitSwitchStatement ( SwitchStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitDoWhileStatement ( DoWhileStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitWhileStatement ( WhileStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitForStatement ( ForStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitForInStatement ( ForInStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitTryCatchStatement ( TryCatchStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitTryFinallyStatement ( TryFinallyStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitDebuggerStatement ( DebuggerStatement * stmt ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitFunctionLiteral ( FunctionLiteral * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitFunctionBoilerplateLiteral ( <nl> + FunctionBoilerplateLiteral * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitConditional ( Conditional * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitRegExpLiteral ( RegExpLiteral * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitObjectLiteral ( ObjectLiteral * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitArrayLiteral ( ArrayLiteral * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCatchExtensionObject ( CatchExtensionObject * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitThrow ( Throw * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitProperty ( Property * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCall ( Call * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCallNew ( CallNew * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCallRuntime ( CallRuntime * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitUnaryOperation ( UnaryOperation * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCountOperation ( CountOperation * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitBinaryOperation ( BinaryOperation * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitCompareOperation ( CompareOperation * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitThisFunction ( ThisFunction * expr ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + <nl> + } } / / namespace v8 : : internal <nl> new file mode 100644 <nl> index 00000000000 . . c5f6202fdcb <nl> mmm / dev / null <nl> ppp b / src / fast - codegen . h <nl> <nl> + / / Copyright 2009 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # ifndef V8_FAST_CODEGEN_H_ <nl> + # define V8_FAST_CODEGEN_H_ <nl> + <nl> + # ifdef V8_TARGET_ARCH_IA32 <nl> + <nl> + # include " v8 . h " <nl> + <nl> + # include " ast . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + class FastCodeGenerator : public AstVisitor { <nl> + public : <nl> + explicit FastCodeGenerator ( MacroAssembler * masm ) <nl> + : masm_ ( masm ) , function_ ( NULL ) { <nl> + } <nl> + <nl> + static Handle < Code > MakeCode ( FunctionLiteral * fun , Handle < Script > script ) ; <nl> + <nl> + void Generate ( FunctionLiteral * fun ) ; <nl> + <nl> + private : <nl> + int SlotOffset ( Slot * slot ) ; <nl> + <nl> + / / AST node visit functions . <nl> + # define DECLARE_VISIT ( type ) virtual void Visit # # type ( type * node ) ; <nl> + AST_NODE_LIST ( DECLARE_VISIT ) <nl> + # undef DECLARE_VISIT <nl> + <nl> + MacroAssembler * masm_ ; <nl> + FunctionLiteral * function_ ; <nl> + <nl> + DISALLOW_COPY_AND_ASSIGN ( FastCodeGenerator ) ; <nl> + } ; <nl> + <nl> + } } / / namespace v8 : : internal <nl> + <nl> + # endif / / V8_TARGET_ARCH_IA32 <nl> + # endif / / V8_FAST_CODEGEN_H_ <nl> mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_bool ( debug_info , true , " add debug information to compiled functions " ) <nl> / / compiler . cc <nl> DEFINE_bool ( strict , false , " strict error checking " ) <nl> DEFINE_int ( min_preparse_length , 1024 , <nl> - " Minimum length for automatic enable preparsing " ) <nl> + " minimum length for automatic enable preparsing " ) <nl> + DEFINE_bool ( fast_compiler , true , <nl> + " use the fast - mode compiler for some top - level code " ) <nl> + DEFINE_bool ( trace_bailout , false , <nl> + " print reasons for failing to use fast compilation " ) <nl> <nl> / / compilation - cache . cc <nl> DEFINE_bool ( compilation_cache , true , " enable compilation cache " ) <nl> mmm a / src / ia32 / codegen - ia32 . h <nl> ppp b / src / ia32 / codegen - ia32 . h <nl> class CodeGenerator : public AstVisitor { <nl> Handle < Script > script , <nl> bool is_eval ) ; <nl> <nl> + / / Printing of AST , etc . as requested by flags . <nl> + static void MakeCodePrologue ( FunctionLiteral * fun ) ; <nl> + <nl> + / / Allocate and install the code . <nl> + static Handle < Code > MakeCodeEpilogue ( FunctionLiteral * fun , <nl> + MacroAssembler * masm , <nl> + Code : : Flags flags , <nl> + Handle < Script > script ) ; <nl> + <nl> # ifdef ENABLE_LOGGING_AND_PROFILING <nl> static bool ShouldGenerateLog ( Expression * type ) ; <nl> # endif <nl> new file mode 100644 <nl> index 00000000000 . . bad25d7646d <nl> mmm / dev / null <nl> ppp b / src / ia32 / fast - codegen - ia32 . cc <nl> <nl> + / / Copyright 2009 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # include " v8 . h " <nl> + <nl> + # include " codegen - inl . h " <nl> + # include " fast - codegen . h " <nl> + / / # include " scopes . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + # define __ ACCESS_MASM ( masm_ ) <nl> + <nl> + / / Generate code for a JS function . On entry to the function the receiver <nl> + / / and arguments have been pushed on the stack left to right , with the <nl> + / / return address on top of them . The actual argument count matches the <nl> + / / formal parameter count expected by the function . <nl> + / / <nl> + / / The live registers are : <nl> + / / o edi : the JS function object being called ( ie , ourselves ) <nl> + / / o esi : our context <nl> + / / o ebp : our caller ' s frame pointer <nl> + / / <nl> + / / The function builds a JS frame . Please see JavaScriptFrameConstants in <nl> + / / frames - ia32 . h for its layout . <nl> + void FastCodeGenerator : : Generate ( FunctionLiteral * fun ) { <nl> + function_ = fun ; <nl> + <nl> + __ push ( ebp ) ; / / Caller ' s frame pointer . <nl> + __ mov ( ebp , esp ) ; <nl> + __ push ( esi ) ; / / Callee ' s context . <nl> + __ push ( edi ) ; / / Callee ' s JS Function . <nl> + <nl> + { Comment cmnt ( masm_ , " [ Allocate locals " ) ; <nl> + int locals_count = fun - > scope ( ) - > num_stack_slots ( ) ; <nl> + for ( int i = 0 ; i < locals_count ; i + + ) { <nl> + __ push ( Immediate ( Factory : : undefined_value ( ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + { Comment cmnt ( masm_ , " [ Stack check " ) ; <nl> + Label ok ; <nl> + ExternalReference stack_guard_limit = <nl> + ExternalReference : : address_of_stack_guard_limit ( ) ; <nl> + __ cmp ( esp , Operand : : StaticVariable ( stack_guard_limit ) ) ; <nl> + __ j ( above_equal , & ok , taken ) ; <nl> + StackCheckStub stub ; <nl> + __ CallStub ( & stub ) ; <nl> + __ bind ( & ok ) ; <nl> + } <nl> + <nl> + { Comment cmnt ( masm_ , " [ Body " ) ; <nl> + VisitStatements ( fun - > body ( ) ) ; <nl> + } <nl> + <nl> + { Comment cmnt ( masm_ , " [ return < undefined > ; " ) ; <nl> + / / Emit a ' return undefined ' in case control fell off the end of the <nl> + / / body . <nl> + __ mov ( eax , Factory : : undefined_value ( ) ) ; <nl> + __ RecordJSReturn ( ) ; <nl> + / / Do not use the leave instruction here because it is too short to <nl> + / / patch with the code required by the debugger . <nl> + __ mov ( esp , ebp ) ; <nl> + __ pop ( ebp ) ; <nl> + __ ret ( ( fun - > scope ( ) - > num_parameters ( ) + 1 ) * kPointerSize ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitExpressionStatement ( ExpressionStatement * stmt ) { <nl> + Comment cmnt ( masm_ , " [ ExpressionStatement " ) ; <nl> + Visit ( stmt - > expression ( ) ) ; <nl> + __ pop ( eax ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitReturnStatement ( ReturnStatement * stmt ) { <nl> + Comment cmnt ( masm_ , " [ ReturnStatement " ) ; <nl> + Visit ( stmt - > expression ( ) ) ; <nl> + __ pop ( eax ) ; <nl> + __ RecordJSReturn ( ) ; <nl> + / / Do not use the leave instruction here because it is too short to <nl> + / / patch with the code required by the debugger . <nl> + __ mov ( esp , ebp ) ; <nl> + __ pop ( ebp ) ; <nl> + __ ret ( ( function_ - > scope ( ) - > num_parameters ( ) + 1 ) * kPointerSize ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitSlot ( Slot * expr ) { <nl> + Comment cmnt ( masm_ , " [ Slot " ) ; <nl> + __ push ( Operand ( ebp , SlotOffset ( expr ) ) ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitVariableProxy ( VariableProxy * expr ) { <nl> + Comment cmnt ( masm_ , " [ VariableProxy " ) ; <nl> + Expression * rewrite = expr - > var ( ) - > rewrite ( ) ; <nl> + ASSERT ( rewrite ! = NULL ) ; <nl> + Visit ( rewrite ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitLiteral ( Literal * expr ) { <nl> + Comment cmnt ( masm_ , " [ Literal " ) ; <nl> + __ push ( Immediate ( expr - > handle ( ) ) ) ; <nl> + } <nl> + <nl> + <nl> + void FastCodeGenerator : : VisitAssignment ( Assignment * expr ) { <nl> + Comment cmnt ( masm_ , " [ Assignment " ) ; <nl> + ASSERT ( expr - > op ( ) = = Token : : ASSIGN | | expr - > op ( ) = = Token : : INIT_VAR ) ; <nl> + <nl> + Visit ( expr - > value ( ) ) ; <nl> + <nl> + Variable * var = expr - > target ( ) - > AsVariableProxy ( ) - > AsVariable ( ) ; <nl> + ASSERT ( var ! = NULL & & var - > slot ( ) ! = NULL ) ; <nl> + __ mov ( eax , Operand ( esp , 0 ) ) ; <nl> + __ mov ( Operand ( ebp , SlotOffset ( var - > slot ( ) ) ) , eax ) ; <nl> + } <nl> + <nl> + <nl> + } } / / namespace v8 : : internal <nl> mmm a / src / v8 - counters . h <nl> ppp b / src / v8 - counters . h <nl> namespace internal { <nl> HT ( variable_allocation , V8 . VariableAllocation ) \ <nl> HT ( ast_optimization , V8 . ASTOptimization ) \ <nl> HT ( code_generation , V8 . CodeGeneration ) \ <nl> - HT ( deferred_code_generation , V8 . DeferredCodeGeneration ) \ <nl> - HT ( code_creation , V8 . CodeCreation ) <nl> + HT ( deferred_code_generation , V8 . DeferredCodeGeneration ) <nl> + <nl> <nl> / / WARNING : STATS_COUNTER_LIST_ * is a very large macro that is causing MSVC <nl> / / Intellisense to crash . It was broken into two macros ( each of length 40 <nl> mmm a / src / x64 / codegen - x64 . h <nl> ppp b / src / x64 / codegen - x64 . h <nl> class CodeGenerator : public AstVisitor { <nl> Handle < Script > script , <nl> bool is_eval ) ; <nl> <nl> + / / Printing of AST , etc . as requested by flags . <nl> + static void MakeCodePrologue ( FunctionLiteral * fun ) ; <nl> + <nl> + / / Allocate and install the code . <nl> + static Handle < Code > MakeCodeEpilogue ( FunctionLiteral * fun , <nl> + MacroAssembler * masm , <nl> + Code : : Flags flags , <nl> + Handle < Script > script ) ; <nl> + <nl> # ifdef ENABLE_LOGGING_AND_PROFILING <nl> static bool ShouldGenerateLog ( Expression * type ) ; <nl> # endif <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ' . . / . . / src / ia32 ' , <nl> ] , <nl> ' sources ' : [ <nl> + ' . . / . . / src / fast - codegen . cc ' , <nl> + ' . . / . . / src / fast - codegen . h ' , <nl> ' . . / . . / src / ia32 / assembler - ia32 - inl . h ' , <nl> ' . . / . . / src / ia32 / assembler - ia32 . cc ' , <nl> ' . . / . . / src / ia32 / assembler - ia32 . h ' , <nl> <nl> ' . . / . . / src / ia32 / cpu - ia32 . cc ' , <nl> ' . . / . . / src / ia32 / debug - ia32 . cc ' , <nl> ' . . / . . / src / ia32 / disasm - ia32 . cc ' , <nl> + ' . . / . . / src / ia32 / fast - codegen . cc ' , <nl> ' . . / . . / src / ia32 / frames - ia32 . cc ' , <nl> ' . . / . . / src / ia32 / frames - ia32 . h ' , <nl> ' . . / . . / src / ia32 / ic - ia32 . cc ' , <nl> mmm a / tools / visual_studio / v8_base . vcproj <nl> ppp b / tools / visual_studio / v8_base . vcproj <nl> <nl> RelativePath = " . . \ . . \ src \ factory . h " <nl> > <nl> < / File > <nl> + < File <nl> + RelativePath = " . . \ . . \ src \ ia32 \ fast - codegen - ia32 . cc " <nl> + > <nl> + < / File > <nl> + < File <nl> + RelativePath = " . . \ . . \ src \ fast - codegen . cc " <nl> + > <nl> + < / File > <nl> + < File <nl> + RelativePath = " . . \ . . \ src \ fast - codegen . h " <nl> + > <nl> + < / File > <nl> < File <nl> RelativePath = " . . \ . . \ src \ flags . cc " <nl> > <nl> | Initial infrastructure for fast compilation of top - level code . The | v8/v8 | f74e723599a7061ee53977479ae0f6c8ef2ac370 | 2009-10-14T19:30:50Z |
mmm a / lib / Sema / CSBindings . cpp <nl> ppp b / lib / Sema / CSBindings . cpp <nl> ConstraintSystem : : getPotentialBindings ( TypeVariableType * typeVar ) { <nl> <nl> / / Make sure we aren ' t trying to equate type variables with different <nl> / / lvalue - binding rules . <nl> - if ( auto otherTypeVar = type - > getAs < TypeVariableType > ( ) ) { <nl> + if ( auto otherTypeVar = <nl> + type - > lookThroughAllOptionalTypes ( ) - > getAs < TypeVariableType > ( ) ) { <nl> if ( typeVar - > getImpl ( ) . canBindToLValue ( ) ! = <nl> otherTypeVar - > getImpl ( ) . canBindToLValue ( ) ) <nl> continue ; <nl> new file mode 100644 <nl> index 000000000000 . . 97385a52d8d2 <nl> mmm / dev / null <nl> ppp b / test / Constraints / rdar37291371 . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift <nl> + <nl> + extension Collection where Element : Numeric { <nl> + var v : Element { <nl> + return self . reduce ( 0 , + ) <nl> + } <nl> + } <nl> + <nl> + struct R < T > { } <nl> + func = = < T : Equatable > ( lhs : R < T > , rhs : T ? ) { } <nl> + <nl> + func foo < T > ( _ e : @ autoclosure @ escaping ( ) throws - > T ? ) - > R < T > { <nl> + return R < T > ( ) <nl> + } <nl> + <nl> + func bar < T > ( _ e : T ? ) - > R < T > { <nl> + return R < T > ( ) <nl> + } <nl> + <nl> + foo ( [ Double ( 1 . 0 ) ] . v ) = = Double ( 1 . 0 ) <nl> + bar ( [ Double ( 1 . 0 ) ] . v ) = = Double ( 1 . 0 ) <nl> similarity index 82 % <nl> rename from validation - test / compiler_crashers / 28625 - destoptionals - size - destextraoptionals - srcoptionals - size . swift <nl> rename to validation - test / compiler_crashers_fixed / 28625 - destoptionals - size - destextraoptionals - srcoptionals - size . swift <nl> mmm a / validation - test / compiler_crashers / 28625 - destoptionals - size - destextraoptionals - srcoptionals - size . swift <nl> ppp b / validation - test / compiler_crashers_fixed / 28625 - destoptionals - size - destextraoptionals - srcoptionals - size . swift <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> - / / RUN : not - - crash % target - swift - frontend % s - emit - ir <nl> - / / REQUIRES : asserts <nl> + / / RUN : not % target - swift - frontend % s - emit - ir <nl> + <nl> nil ? as ? Int ? ? <nl> similarity index 87 % <nl> rename from validation - test / compiler_crashers / 28866 - unreachable - executed - at - swift - include - swift - ast - cantypevisitor - h - 41 . swift <nl> rename to validation - test / compiler_crashers_fixed / 28866 - unreachable - executed - at - swift - include - swift - ast - cantypevisitor - h - 41 . swift <nl> mmm a / validation - test / compiler_crashers / 28866 - unreachable - executed - at - swift - include - swift - ast - cantypevisitor - h - 41 . swift <nl> ppp b / validation - test / compiler_crashers_fixed / 28866 - unreachable - executed - at - swift - include - swift - ast - cantypevisitor - h - 41 . swift <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> - / / RUN : not - - crash % target - swift - frontend % s - emit - ir <nl> + / / RUN : not % target - swift - frontend % s - emit - ir <nl> [ . a <nl> [ Int ? as ? Int <nl> nil ? <nl> | [ CSBindings ] Look through optional types when trying to validate l - valueness of the new bindings | apple/swift | c6ff7b40cc25ccc9eb7e895db7ca40a31add0019 | 2018-02-08T09:55:39Z |
mmm a / arangod / Aql / AqlItemBlock . h <nl> ppp b / arangod / Aql / AqlItemBlock . h <nl> namespace triagens { <nl> TRI_ASSERT ( _data . capacity ( ) > index * _nrRegs + varNr ) ; <nl> return _data [ index * _nrRegs + varNr ] ; <nl> } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief getValue , get the value of a register by reference <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + AqlValue const & getValueReference ( size_t index , RegisterId varNr ) const { <nl> + TRI_ASSERT ( _data . capacity ( ) > index * _nrRegs + varNr ) ; <nl> + return _data [ index * _nrRegs + varNr ] ; <nl> + } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief setValue , set the current value of a register <nl> mmm a / arangod / Aql / AqlValue . cpp <nl> ppp b / arangod / Aql / AqlValue . cpp <nl> AqlValue AqlValue : : CreateFromBlocks ( triagens : : arango : : AqlTransaction * trx , <nl> for ( auto it = src . begin ( ) ; it ! = src . end ( ) ; + + it ) { <nl> auto current = ( * it ) ; <nl> RegisterId const n = current - > getNrRegs ( ) ; <nl> + <nl> + std : : vector < std : : pair < RegisterId , TRI_document_collection_t const * > > registers ; <nl> + for ( RegisterId j = 0 ; j < n ; + + j ) { <nl> + / / temporaries don ' t have a name and won ' t be included <nl> + if ( variableNames [ j ] [ 0 ] ! = ' \ 0 ' ) { <nl> + registers . emplace_back ( std : : make_pair ( j , current - > getDocumentCollection ( j ) ) ) ; <nl> + } <nl> + } <nl> <nl> for ( size_t i = 0 ; i < current - > size ( ) ; + + i ) { <nl> - Json values ( Json : : Array ) ; <nl> - <nl> - for ( RegisterId j = 0 ; j < n ; + + j ) { <nl> - if ( variableNames [ j ] [ 0 ] ! = ' \ 0 ' ) { <nl> - / / temporaries don ' t have a name and won ' t be included <nl> - / / Variables from depth 0 are excluded , too , unless the <nl> - / / COLLECT statement is on level 0 as well . <nl> - values . set ( variableNames [ j ] . c_str ( ) , current - > getValue ( i , j ) . toJson ( trx , current - > getDocumentCollection ( j ) ) ) ; <nl> - } <nl> + Json values ( Json : : Array , registers . size ( ) ) ; <nl> + <nl> + / / only enumerate the registers that are left <nl> + for ( auto const & reg : registers ) { <nl> + values . set ( variableNames [ reg . first ] , current - > getValueReference ( i , reg . first ) . toJson ( trx , reg . second ) ) ; <nl> } <nl> <nl> json - > add ( values ) ; <nl> mmm a / lib / Basics / JsonHelper . h <nl> ppp b / lib / Basics / JsonHelper . h <nl> namespace triagens { <nl> TRI_Insert3ArrayJson ( _zone , _json , name , sub . steal ( ) ) ; <nl> return * this ; <nl> } <nl> + <nl> + Json & set ( std : : string const & name , Json sub ) { <nl> + if ( ! TRI_IsArrayJson ( _json ) ) { <nl> + throw JsonException ( " Json is no array " ) ; <nl> + } <nl> + TRI_Insert3ArrayJson ( _zone , _json , name . c_str ( ) , sub . steal ( ) ) ; <nl> + return * this ; <nl> + } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief this is a syntactic shortcut for the set method using operator ( ) <nl> | optimizations | arangodb/arangodb | cc00bb8897391d15120dc30614f46d1aa14ec1f2 | 2014-12-04T15:33:48Z |
mmm a / editor / scene_tree_dock . cpp <nl> ppp b / editor / scene_tree_dock . cpp <nl> void SceneTreeDock : : _tool_selected ( int p_tool , bool p_confirm_override ) { <nl> if ( e ) { <nl> Node * node = e - > get ( ) ; <nl> if ( node ) { <nl> + bool editable = EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > is_editable_instance ( node ) ; <nl> bool placeholder = node - > get_scene_instance_load_placeholder ( ) ; <nl> + <nl> + / / Fire confirmation dialog when children are editable . <nl> + if ( editable & & ! placeholder ) { <nl> + placeholder_editable_instance_remove_dialog - > set_text ( TTR ( " Enabling \ " Load As Placeholder \ " will disable \ " Editable Children \ " and cause all properties of the node to be reverted to their default . " ) ) ; <nl> + placeholder_editable_instance_remove_dialog - > popup_centered_minsize ( ) ; <nl> + break ; <nl> + } <nl> + <nl> placeholder = ! placeholder ; <nl> - int editable_item_idx = menu - > get_item_idx_from_text ( TTR ( " Editable Children " ) ) ; <nl> - int placeholder_item_idx = menu - > get_item_idx_from_text ( TTR ( " Load As Placeholder " ) ) ; <nl> + <nl> if ( placeholder ) <nl> EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > set_editable_instance ( node , false ) ; <nl> <nl> node - > set_scene_instance_load_placeholder ( placeholder ) ; <nl> - menu - > set_item_checked ( editable_item_idx , false ) ; <nl> - menu - > set_item_checked ( placeholder_item_idx , placeholder ) ; <nl> scene_tree - > update_tree ( ) ; <nl> } <nl> } <nl> void SceneTreeDock : : _toggle_editable_children_from_selection ( ) { <nl> } <nl> } <nl> <nl> + void SceneTreeDock : : _toggle_placeholder_from_selection ( ) { <nl> + <nl> + List < Node * > selection = editor_selection - > get_selected_node_list ( ) ; <nl> + List < Node * > : : Element * e = selection . front ( ) ; <nl> + <nl> + if ( e ) { <nl> + Node * node = e - > get ( ) ; <nl> + if ( node ) { <nl> + _toggle_editable_children ( node ) ; <nl> + <nl> + bool placeholder = node - > get_scene_instance_load_placeholder ( ) ; <nl> + placeholder = ! placeholder ; <nl> + <nl> + node - > set_scene_instance_load_placeholder ( placeholder ) ; <nl> + scene_tree - > update_tree ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> void SceneTreeDock : : _toggle_editable_children ( Node * p_node ) { <nl> <nl> if ( p_node ) { <nl> void SceneTreeDock : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " _nodes_drag_begin " ) , & SceneTreeDock : : _nodes_drag_begin ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _delete_confirm " ) , & SceneTreeDock : : _delete_confirm ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _toggle_editable_children_from_selection " ) , & SceneTreeDock : : _toggle_editable_children_from_selection ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " _toggle_placeholder_from_selection " ) , & SceneTreeDock : : _toggle_placeholder_from_selection ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _node_prerenamed " ) , & SceneTreeDock : : _node_prerenamed ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _import_subscene " ) , & SceneTreeDock : : _import_subscene ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _selection_changed " ) , & SceneTreeDock : : _selection_changed ) ; <nl> SceneTreeDock : : SceneTreeDock ( EditorNode * p_editor , Node * p_scene_root , EditorSel <nl> add_child ( editable_instance_remove_dialog ) ; <nl> editable_instance_remove_dialog - > connect ( " confirmed " , this , " _toggle_editable_children_from_selection " ) ; <nl> <nl> + placeholder_editable_instance_remove_dialog = memnew ( ConfirmationDialog ) ; <nl> + add_child ( placeholder_editable_instance_remove_dialog ) ; <nl> + placeholder_editable_instance_remove_dialog - > connect ( " confirmed " , this , " _toggle_placeholder_from_selection " ) ; <nl> + <nl> import_subscene_dialog = memnew ( EditorSubScene ) ; <nl> add_child ( import_subscene_dialog ) ; <nl> import_subscene_dialog - > connect ( " subscene_selected " , this , " _import_subscene " ) ; <nl> mmm a / editor / scene_tree_dock . h <nl> ppp b / editor / scene_tree_dock . h <nl> class SceneTreeDock : public VBoxContainer { <nl> AcceptDialog * accept ; <nl> ConfirmationDialog * delete_dialog ; <nl> ConfirmationDialog * editable_instance_remove_dialog ; <nl> + ConfirmationDialog * placeholder_editable_instance_remove_dialog ; <nl> <nl> ReparentDialog * reparent_dialog ; <nl> EditorQuickOpen * quick_open ; <nl> class SceneTreeDock : public VBoxContainer { <nl> void _toggle_editable_children_from_selection ( ) ; <nl> void _toggle_editable_children ( Node * p_node ) ; <nl> <nl> + void _toggle_placeholder_from_selection ( ) ; <nl> + <nl> void _node_prerenamed ( Node * p_node , const String & p_new_name ) ; <nl> <nl> void _nodes_drag_begin ( ) ; <nl> | Placeholder dialog for editable children | godotengine/godot | cb528e31d9dc12e0add690112392765d57b1571d | 2019-09-27T17:49:55Z |
new file mode 100644 <nl> index 000000000000 . . 4bc21ed2505b <nl> mmm / dev / null <nl> ppp b / jstests / bench_test3 . js <nl> <nl> + t = db . bench_test3 <nl> + t . drop ( ) ; <nl> + <nl> + <nl> + benchArgs = { ops : [ { ns : t . getFullName ( ) , <nl> + op : " update " , <nl> + upsert : true , <nl> + query : { _id : { " # RAND_INT " : [ 0 , 5 , 4 ] } } , <nl> + update : { $ inc : { x : 1 } } } ] , <nl> + parallel : 2 , <nl> + seconds : 1 , <nl> + totals : true , <nl> + host : db . getMongo ( ) . host } <nl> + <nl> + if ( jsTest . options ( ) . auth ) { <nl> + benchArgs [ ' db ' ] = ' admin ' ; <nl> + benchArgs [ ' username ' ] = jsTest . options ( ) . adminUser ; <nl> + benchArgs [ ' password ' ] = jsTest . options ( ) . adminPassword ; <nl> + } <nl> + <nl> + res = benchRun ( benchArgs ) <nl> + printjson ( res ) ; <nl> + <nl> + var keys = [ ] <nl> + var totals = { } <nl> + db . bench_test3 . find ( ) . sort ( { _id : 1 } ) . forEach ( function ( z ) { keys . push ( z . _id ) ; totals [ z . _id ] = z . x } ) ; <nl> + assert . eq ( [ 0 , 4 , 8 , 12 , 16 ] , keys ) <nl> mmm a / src / mongo / scripting / bench . cpp <nl> ppp b / src / mongo / scripting / bench . cpp <nl> namespace mongo { <nl> int max = i . next ( ) . numberInt ( ) ; <nl> <nl> int x = min + ( rand ( ) % ( max - min ) ) ; <nl> + <nl> + if ( i . more ( ) ) <nl> + x * = i . next ( ) . numberInt ( ) ; <nl> + <nl> b . append ( e . fieldName ( ) , x ) ; <nl> } <nl> else { <nl> | RAND_INT takes a multiplier | mongodb/mongo | f3744095b94d264ad83a11d0eb0faea2862f01eb | 2012-03-13T13:53:10Z |
mmm a / cocos / 2d / CCSprite . h <nl> ppp b / cocos / 2d / CCSprite . h <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # ifndef __SPITE_NODE_CCSPRITE_H__ <nl> - # define __SPITE_NODE_CCSPRITE_H__ <nl> + # ifndef __SPRITE_NODE_CCSPRITE_H__ <nl> + # define __SPRITE_NODE_CCSPRITE_H__ <nl> <nl> # include " CCNode . h " <nl> # include " CCProtocols . h " <nl> struct transformValues_ ; <nl> * @ { <nl> * / <nl> <nl> - / * * <nl> + / * * <nl> * Sprite is a 2d image ( http : / / en . wikipedia . org / wiki / Sprite_ ( computer_graphics ) ) <nl> * <nl> * Sprite can be created with an image , or with a sub - rectangle of an image . <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> <nl> / / / @ { <nl> / / / @ name Creators <nl> - <nl> + <nl> / * * <nl> * Creates an empty sprite without texture . You can call setTexture method subsequently . <nl> * <nl> * @ return An empty sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * create ( ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with an image filename . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * create ( const std : : string & filename ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with an image filename and a rect . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * create ( const std : : string & filename , const Rect & rect ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with an exsiting texture contained in a Texture2D object <nl> * After creation , the rect will be the size of the texture , and the offset will be ( 0 , 0 ) . <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * createWithTexture ( Texture2D * texture ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with a texture and a rect . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * createWithTexture ( Texture2D * texture , const Rect & rect ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with an sprite frame . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * createWithSpriteFrame ( SpriteFrame * pSpriteFrame ) ; <nl> - <nl> + <nl> / * * <nl> * Creates a sprite with an sprite frame name . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return A valid sprite object that is marked as autoreleased . <nl> * / <nl> static Sprite * createWithSpriteFrameName ( const std : : string & spriteFrameName ) ; <nl> - <nl> + <nl> / / / @ } end of creators group <nl> - <nl> - <nl> + <nl> + <nl> / / / @ { <nl> / / / @ name Initializers <nl> - <nl> + <nl> / * * <nl> * Default constructor <nl> * @ js ctor <nl> * / <nl> Sprite ( void ) ; <nl> - <nl> + <nl> / * * <nl> * Default destructor <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> virtual ~ Sprite ( void ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes an empty sprite with nothing init . <nl> * / <nl> virtual bool init ( void ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with a texture . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return true if the sprite is initialized properly , false otherwise . <nl> * / <nl> virtual bool initWithTexture ( Texture2D * texture ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with a texture and a rect . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return true if the sprite is initialized properly , false otherwise . <nl> * / <nl> virtual bool initWithTexture ( Texture2D * texture , const Rect & rect ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with a texture and a rect in points , optionally rotated . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return true if the sprite is initialized properly , false otherwise . <nl> * / <nl> virtual bool initWithTexture ( Texture2D * texture , const Rect & rect , bool rotated ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with an SpriteFrame . The texture and rect in SpriteFrame will be applied on this sprite <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return true if the sprite is initialized properly , false otherwise . <nl> * / <nl> virtual bool initWithSpriteFrame ( SpriteFrame * pSpriteFrame ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with an sprite frame name . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ return true if the sprite is initialized properly , false otherwise . <nl> * / <nl> virtual bool initWithSpriteFrameName ( const std : : string & spriteFrameName ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with an image filename . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ lua init <nl> * / <nl> virtual bool initWithFile ( const std : : string & filename ) ; <nl> - <nl> + <nl> / * * <nl> * Initializes a sprite with an image filename , and a rect . <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ lua init <nl> * / <nl> virtual bool initWithFile ( const std : : string & filename , const Rect & rect ) ; <nl> - <nl> + <nl> / / / @ } end of initializers <nl> <nl> / / / @ { <nl> / / / @ name BatchNode methods <nl> - <nl> + <nl> / * * <nl> - * Updates the quad according the rotation , position , scale values . <nl> + * Updates the quad according the rotation , position , scale values . <nl> * / <nl> virtual void updateTransform ( void ) ; <nl> - <nl> + <nl> / * * <nl> * Returns the batch node object if this sprite is rendered by SpriteBatchNode <nl> * <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * @ endcode <nl> * / <nl> virtual void setBatchNode ( SpriteBatchNode * spriteBatchNode ) ; <nl> - <nl> + <nl> / / / @ } end of BatchNode methods <nl> - <nl> - <nl> - <nl> + <nl> + <nl> + <nl> / / / @ { <nl> / / / @ name Texture methods <nl> - <nl> + <nl> / * * <nl> * Updates the texture rect of the Sprite in points . <nl> * It will call setTextureRect ( const Rect & rect , bool rotated , const Size & untrimmedSize ) with \ p rotated = false , and \ p utrimmedSize = rect . size . <nl> * / <nl> virtual void setTextureRect ( const Rect & rect ) ; <nl> - <nl> + <nl> / * * <nl> * Sets the texture rect , rectRotated and untrimmed size of the Sprite in points . <nl> * It will update the texture coordinates and the vertex rectangle . <nl> * / <nl> virtual void setTextureRect ( const Rect & rect , bool rotated , const Size & untrimmedSize ) ; <nl> - <nl> + <nl> / * * <nl> * Sets the vertex rect . <nl> * It will be called internally by setTextureRect . <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * Do not call it manually . Use setTextureRect instead . <nl> * / <nl> virtual void setVertexRect ( const Rect & rect ) ; <nl> - <nl> + <nl> / / / @ } end of texture methods <nl> - <nl> <nl> - <nl> + <nl> + <nl> / / / @ { <nl> / / / @ name Frames methods <nl> - <nl> + <nl> / * * <nl> * Sets a new display frame to the Sprite . <nl> * / <nl> virtual void setDisplayFrame ( SpriteFrame * pNewFrame ) ; <nl> - <nl> + <nl> / * * <nl> * Returns whether or not a SpriteFrame is being displayed <nl> * / <nl> virtual bool isFrameDisplayed ( SpriteFrame * pFrame ) const ; <nl> - <nl> + <nl> / * * @ deprecated Use getDisplayFrame ( ) instead * / <nl> CC_DEPRECATED_ATTRIBUTE virtual SpriteFrame * displayFrame ( ) { return getDisplayFrame ( ) ; } ; <nl> - <nl> + <nl> / * * <nl> * Returns the current displayed frame . <nl> * / <nl> virtual SpriteFrame * getDisplayFrame ( ) ; <nl> - <nl> + <nl> / / / @ } End of frames methods <nl> - <nl> + <nl> <nl> / / / @ { <nl> / / / @ name Animation methods <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * / <nl> virtual void setDisplayFrameWithAnimationName ( const std : : string & animationName , int frameIndex ) ; <nl> / / / @ } <nl> - <nl> - <nl> + <nl> + <nl> / / / @ { <nl> / / / @ name Sprite Properties ' setter / getters <nl> - <nl> - / * * <nl> + <nl> + / * * <nl> * Whether or not the Sprite needs to be updated in the Atlas . <nl> * <nl> * @ return true if the sprite needs to be updated in the Atlas , false otherwise . <nl> * / <nl> virtual bool isDirty ( void ) const { return _dirty ; } <nl> - <nl> - / * * <nl> + <nl> + / * * <nl> * Makes the Sprite to be updated in the Atlas . <nl> * / <nl> virtual void setDirty ( bool bDirty ) { _dirty = bDirty ; } <nl> - <nl> + <nl> / * * <nl> * Returns the quad ( tex coords , vertex coords and color ) information . <nl> * @ js NA <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * / <nl> inline V3F_C4B_T2F_Quad getQuad ( void ) const { return _quad ; } <nl> <nl> - / * * <nl> + / * * <nl> * Returns whether or not the texture rectangle is rotated . <nl> * / <nl> inline bool isTextureRectRotated ( void ) const { return _rectRotated ; } <nl> - <nl> - / * * <nl> - * Returns the index used on the TextureAtlas . <nl> + <nl> + / * * <nl> + * Returns the index used on the TextureAtlas . <nl> * / <nl> inline int getAtlasIndex ( void ) const { return _atlasIndex ; } <nl> - <nl> - / * * <nl> + <nl> + / * * <nl> * Sets the index used on the TextureAtlas . <nl> * @ warning Don ' t modify this value unless you know what you are doing <nl> * / <nl> inline void setAtlasIndex ( int atlasIndex ) { _atlasIndex = atlasIndex ; } <nl> <nl> - / * * <nl> - * Returns the rect of the Sprite in points <nl> + / * * <nl> + * Returns the rect of the Sprite in points <nl> * / <nl> inline const Rect & getTextureRect ( void ) { return _rect ; } <nl> <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * Gets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode <nl> * / <nl> inline TextureAtlas * getTextureAtlas ( void ) { return _textureAtlas ; } <nl> - <nl> + <nl> / * * <nl> * Sets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode <nl> * / <nl> inline void setTextureAtlas ( TextureAtlas * pobTextureAtlas ) { _textureAtlas = pobTextureAtlas ; } <nl> <nl> - / * * <nl> + / * * <nl> * Gets the offset position of the sprite . Calculated automatically by editors like Zwoptex . <nl> * / <nl> inline const Point & getOffsetPosition ( void ) const { return _offsetPosition ; } <nl> <nl> <nl> - / * * <nl> + / * * <nl> * Returns the flag which indicates whether the sprite is flipped horizontally or not . <nl> * <nl> * It only flips the texture of the sprite , and not the texture of the sprite ' s children . <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> * If you want to flip the anchorPoint too , and / or to flip the children too use : <nl> * sprite - > setScaleX ( sprite - > getScaleX ( ) * - 1 ) ; <nl> * <nl> - * @ return true if the sprite is flipped horizaontally , false otherwise . <nl> + * @ return true if the sprite is flipped horizontally , false otherwise . <nl> * / <nl> bool isFlippedX ( void ) const ; <nl> / * * <nl> * Sets whether the sprite should be flipped horizontally or not . <nl> * <nl> - * @ param bFlipX true if the sprite should be flipped horizaontally , false otherwise . <nl> + * @ param flippedX true if the sprite should be flipped horizontally , false otherwise . <nl> * / <nl> void setFlippedX ( bool flippedX ) ; <nl> - <nl> - / * * @ deprecated Use isFlippedX ( ) instead <nl> + <nl> + / * * @ deprecated Use isFlippedX ( ) instead <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> CC_DEPRECATED_ATTRIBUTE bool isFlipX ( ) { return isFlippedX ( ) ; } ; <nl> / * * @ deprecated Use setFlippedX ( ) instead * / <nl> - CC_DEPRECATED_ATTRIBUTE void setFlipX ( bool flippedX ) { setFlippedX ( flippedX ) ; } ; <nl> - <nl> - / * * <nl> + CC_DEPRECATED_ATTRIBUTE void setFlipX ( bool flippedX ) { setFlippedX ( flippedX ) ; } ; <nl> + <nl> + / * * <nl> * Return the flag which indicates whether the sprite is flipped vertically or not . <nl> - * <nl> + * <nl> * It only flips the texture of the sprite , and not the texture of the sprite ' s children . <nl> * Also , flipping the texture doesn ' t alter the anchorPoint . <nl> * If you want to flip the anchorPoint too , and / or to flip the children too use : <nl> * sprite - > setScaleY ( sprite - > getScaleY ( ) * - 1 ) ; <nl> - * <nl> - * @ return true if the sprite is flipped vertically , flase otherwise . <nl> + * <nl> + * @ return true if the sprite is flipped vertically , false otherwise . <nl> * / <nl> bool isFlippedY ( void ) const ; <nl> / * * <nl> * Sets whether the sprite should be flipped vertically or not . <nl> * <nl> - * @ param bFlipY true if the sprite should be flipped vertically , flase otherwise . <nl> + * @ param flippedY true if the sprite should be flipped vertically , false otherwise . <nl> * / <nl> void setFlippedY ( bool flippedY ) ; <nl> - <nl> + <nl> / / / @ } End of Sprite properties getter / setters <nl> - <nl> + <nl> / * * @ deprecated Use isFlippedY ( ) instead * / <nl> CC_DEPRECATED_ATTRIBUTE bool isFlipY ( ) { return isFlippedY ( ) ; } ; <nl> / * * @ deprecated Use setFlippedY ( ) instead * / <nl> - CC_DEPRECATED_ATTRIBUTE void setFlipY ( bool flippedY ) { setFlippedY ( flippedY ) ; } ; <nl> + CC_DEPRECATED_ATTRIBUTE void setFlipY ( bool flippedY ) { setFlippedY ( flippedY ) ; } ; <nl> <nl> / / <nl> / / Overrides <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> TextureAtlas * _textureAtlas ; / / / SpriteBatchNode texture atlas ( weak reference ) <nl> int _atlasIndex ; / / / Absolute ( real ) Index on the SpriteSheet <nl> SpriteBatchNode * _batchNode ; / / / Used batch node ( weak reference ) <nl> - <nl> + <nl> bool _dirty ; / / / Whether the sprite needs to be updated <nl> bool _recursiveDirty ; / / / Whether all of the sprite ' s children needs to be updated <nl> bool _hasChildren ; / / / Whether the sprite contains children <nl> bool _shouldBeHidden ; / / / should not be drawn because one of the ancestors is not visible <nl> AffineTransform _transformToBatch ; <nl> - <nl> + <nl> / / <nl> / / Data used when the sprite is self - rendered <nl> / / <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> bool _opacityModifyRGB ; <nl> <nl> / / image is flipped <nl> - bool _flippedX ; / / / Whether the sprite is flipped horizaontally or not . <nl> - bool _flippedY ; / / / Whether the sprite is flipped vertically or not . <nl> + bool _flippedX ; / / / Whether the sprite is flipped horizontally or not <nl> + bool _flippedY ; / / / Whether the sprite is flipped vertically or not <nl> } ; <nl> <nl> <nl> class CC_DLL Sprite : public NodeRGBA , public TextureProtocol <nl> <nl> NS_CC_END <nl> <nl> - # endif / / __SPITE_NODE_CCSPRITE_H__ <nl> + # endif / / __SPRITE_NODE_CCSPRITE_H__ <nl> | Fix typos and other trivial cleanup | cocos2d/cocos2d-x | 27b82f8f67c4a0c82523a2d4f3a113ec10f118e4 | 2013-11-11T03:00:50Z |
new file mode 100644 <nl> index 0000000000 . . a2bad95485 <nl> mmm / dev / null <nl> ppp b / code / search / jump_search / jump_search . rs <nl> <nl> + / / Part of Cosmos by OpenGenus Foundation <nl> + use std : : cmp : : min ; <nl> + <nl> + fn jump_search ( arr : Vec < i32 > , n : i32 ) - > i32 { <nl> + let mut step = ( arr . len ( ) as f64 ) . sqrt ( ) as usize ; <nl> + let len = arr . len ( ) ; <nl> + let mut prev : usize = 0 ; <nl> + <nl> + / / Jumps <nl> + while arr [ min ( step , len ) - 1 ] < n { <nl> + prev = step ; <nl> + step + = step ; <nl> + if prev > = len { <nl> + return - 1 <nl> + } <nl> + } <nl> + / / Linear search <nl> + while arr [ prev ] < n { <nl> + prev + = 1 ; <nl> + if arr [ prev ] = = ( min ( step , len ) ) as i32 { <nl> + return - 1 <nl> + } <nl> + } <nl> + / / Element found <nl> + if arr [ prev ] = = n { <nl> + return prev as i32 <nl> + } <nl> + - 1 <nl> + } <nl> + <nl> + fn main ( ) { <nl> + let arr = vec ! [ 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 , 377 , 610 ] ; <nl> + println ! ( " Found { } at index { } " , 55 , jump_search ( arr , 55 ) ) ; <nl> + } <nl> \ No newline at end of file <nl> | Merge pull request from Jay9596 / Rust_jumpSearch | OpenGenus/cosmos | 85af8b15f530338ab25c3671389b851eff6c6740 | 2017-10-11T16:46:56Z |
mmm a / tensorflow / core / framework / model . cc <nl> ppp b / tensorflow / core / framework / model . cc <nl> class Unknown : public Node { <nl> <nl> } / / namespace <nl> <nl> + thread_local int64 Node : : work_start_ ; <nl> + <nl> std : : shared_ptr < Parameter > MakeParameter ( const string & name , <nl> std : : shared_ptr < SharedState > state , <nl> double min , double max ) { <nl> mmm a / tensorflow / core / framework / model . h <nl> ppp b / tensorflow / core / framework / model . h <nl> class Node { <nl> <nl> / / Records that a node thread has started executing . <nl> void record_start ( int64 time_nanos ) TF_LOCKS_EXCLUDED ( mu_ ) { <nl> - mutex_lock l ( mu_ ) ; <nl> - work_start_ [ std : : this_thread : : get_id ( ) ] = time_nanos ; <nl> + DCHECK_EQ ( work_start_ , 0 ) ; <nl> + work_start_ = time_nanos ; <nl> } <nl> <nl> / / Records that a node thread has stopped executing . <nl> void record_stop ( int64 time_nanos ) TF_LOCKS_EXCLUDED ( mu_ ) { <nl> - mutex_lock l ( mu_ ) ; <nl> - std : : thread : : id tid = std : : this_thread : : get_id ( ) ; <nl> - auto iter = work_start_ . find ( tid ) ; <nl> - if ( iter ! = work_start_ . end ( ) ) { <nl> - processing_time_ + = time_nanos - iter - > second ; <nl> - work_start_ . erase ( iter ) ; <nl> + if ( work_start_ ! = 0 ) { <nl> + processing_time_ + = time_nanos - work_start_ ; <nl> + work_start_ = 0 ; <nl> } else { <nl> VLOG ( 1 ) < < " Encountered a stop event without a matching start event . " ; <nl> } <nl> class Node { <nl> void TotalMaximumBufferedBytesHelper ( <nl> absl : : flat_hash_map < string , double > * total_bytes ) const ; <nl> <nl> + / / Stores the time passed to the last call to ` Node : : record_start ( ) ` on the <nl> + / / current thread . <nl> + / / <nl> + / / NOTE : This thread - local variable is shared between all instances of ` Node ` <nl> + / / on which the same thread calls ` record_start ( ) ` or ` record_stop ( ) ` . It <nl> + / / relies on the invariant that at most one ` Node ` can be " active " on a <nl> + / / particular thread at any time . Therefore if ` n - > record_start ( ) ` is called <nl> + / / on thread ` t ` , then ` n - > record_stop ( ) ` must be called before another call <nl> + / / to ` Node : : record_start ( ) ` ( for any node ) . <nl> + static thread_local int64 work_start_ ; / / Will be initialized to zero . <nl> + <nl> mutable mutex mu_ ; <nl> const int64 id_ ; <nl> const string name_ ; <nl> class Node { <nl> Metrics metrics_ ; <nl> absl : : flat_hash_map < string , std : : shared_ptr < Parameter > > parameters_ <nl> TF_GUARDED_BY ( mu_ ) ; <nl> - absl : : flat_hash_map < std : : thread : : id , int64 > work_start_ TF_GUARDED_BY ( mu_ ) ; <nl> <nl> / / Statistic of inputs processing time history . <nl> double input_processing_time_sum_ = 0 . 0L ; <nl> mmm a / tensorflow / core / kernels / data / cache_dataset_ops . cc <nl> ppp b / tensorflow / core / kernels / data / cache_dataset_ops . cc <nl> class CacheDatasetOp : : MemoryDatasetBase : public DatasetBase { <nl> std : : vector < Tensor > * out_tensors , <nl> bool * end_of_sequence ) override { <nl> mutex_lock l ( mu_ ) ; <nl> - return iterator_ - > GetNext ( ctx , out_tensors , end_of_sequence ) ; <nl> + / / TODO ( b / 154341936 ) : Explicitly stopping and starting this iterator <nl> + / / should not be necessary , but the ` kImpl ` added to the prefix passed <nl> + / / to ` iterator_ ` when it was created prevents the model from identifying <nl> + / / this iterator as the output of ` iterator_ ` . <nl> + RecordStop ( ctx ) ; <nl> + Status s = iterator_ - > GetNext ( ctx , out_tensors , end_of_sequence ) ; <nl> + RecordStart ( ctx ) ; <nl> + return s ; <nl> } <nl> <nl> protected : <nl> | [ tf . data ] Use thread - local start time instead of thread - id map in ` model : : Node ` . | tensorflow/tensorflow | 75940041fc857971b440c35da52937589e229737 | 2020-04-21T22:14:34Z |
mmm a / tensorflow / lite / experimental / micro / README . md <nl> ppp b / tensorflow / lite / experimental / micro / README . md <nl> You should see the following log with the magic string ` ~ ~ ~ ALL TEST PASSED ~ ~ ~ ` : <nl> <nl> Follow these steps to get the pushbutton yes / no example working on Apollo 3 : <nl> <nl> - 1 . Make sure to run the " Getting Started " section before performing the <nl> - following steps <nl> - 2 . Download Apollo3 - SDK - 2018 . 08 . 13 and place in <nl> - ` tensorflow / lite / experimental / micro / tools / make / downloads ` . This is not yet <nl> - publicly released , but you can contact ashah @ ambiqmicro . com to request a <nl> - copy . <nl> + 1 . Make sure to run the " Building Portable Reference Code using Make " section <nl> + before performing the following steps <nl> + 2 . The Ambiq Micro SDK is downloaded into <nl> + ` tensorflow / lite / experimental / micro / tools / make / downloads ` by <nl> + ' download_dependencies . sh ' . <nl> 3 . Compile the project with the following command : make - f <nl> tensorflow / lite / experimental / micro / tools / make / Makefile TARGET = apollo3evb <nl> pushbutton_cmsis_speech_test_bin <nl> Follow these steps to get the pushbutton yes / no example working on Apollo 3 : <nl> 4 . Press BTN2 . An LED will flash for 1 second . Speak your utterance during <nl> this one second <nl> 5 . The debugger will print out four numbers . They are the probabilites for <nl> - 1 ) no speech , 2 ) unknown speech , 3 ) yes , 4 ) no <nl> + 1 . no speech <nl> + 2 . unkown speech <nl> + 3 . yes <nl> + 4 . no <nl> 6 . The EVB LEDs will indicate detection . <nl> 1 . LED0 ( rightmost LED ) - ON when capturing 1sec of audio <nl> 2 . LED1 - ON when detecting silence <nl> mmm a / tensorflow / lite / experimental / micro / examples / micro_speech / apollo3 / pushbutton_main . c <nl> ppp b / tensorflow / lite / experimental / micro / examples / micro_speech / apollo3 / pushbutton_main . c <nl> void pdm_data_get ( void ) { <nl> / / PDM interrupt handler . <nl> / / <nl> / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - void am_pdm_isr ( void ) { <nl> + void am_pdm0_isr ( void ) { <nl> uint32_t ui32Status ; <nl> / / <nl> / / Read the interrupt status . <nl> mmm a / tensorflow / lite / experimental / micro / tools / make / Makefile <nl> ppp b / tensorflow / lite / experimental / micro / tools / make / Makefile <nl> $ ( BINDIR ) % _test : $ ( OBJDIR ) % _test . o $ ( MICROLITE_LIB_PATH ) <nl> $ ( BINDIR ) % . test_target : $ ( BINDIR ) % _test <nl> $ ( TEST_SCRIPT ) $ < ' ~ ~ ~ ALL TESTS PASSED ~ ~ ~ ' <nl> <nl> + # snease : Add % . bin rule here since BINDIR is now defined <nl> + # These are microcontroller - specific rules for converting the ELF output <nl> + # of the linker into a binary image that can be loaded directly . <nl> + OBJCOPY : = $ ( TARGET_TOOLCHAIN_PREFIX ) objcopy <nl> + $ ( BINDIR ) % . bin : $ ( BINDIR ) % <nl> + @ mkdir - p $ ( dir $ @ ) <nl> + $ ( OBJCOPY ) $ < $ @ - O binary <nl> + <nl> # Generate standalone makefile projects for all of the test targets . <nl> $ ( foreach TEST_TARGET , $ ( MICROLITE_TEST_SRCS ) , \ <nl> $ ( eval $ ( call microlite_test , $ ( notdir $ ( basename $ ( TEST_TARGET ) ) ) , $ ( TEST_TARGET ) ) ) ) <nl> mmm a / tensorflow / lite / experimental / micro / tools / make / download_dependencies . sh <nl> ppp b / tensorflow / lite / experimental / micro / tools / make / download_dependencies . sh <nl> CMSIS_URL = " https : / / github . com / ARM - software / CMSIS_5 / archive / 5 . 4 . 0 . zip " <nl> STM32_BARE_LIB_URL = " https : / / github . com / google / stm32_bare_lib / archive / c07d611fb0af58450c5a3e0ab4d52b47f99bc82d . zip " <nl> SIFIVE_FE310_LIB_URL = " https : / / github . com / sifive / freedom - e - sdk / archive / baeeb8fd497a99b3c141d7494309ec2e64f19bdf . zip " <nl> RISCV_TOOLCHAIN_URL = " https : / / static . dev . sifive . com / dev - tools / riscv64 - unknown - elf - gcc - 20181030 - x86_64 - linux - ubuntu14 . tar . gz " <nl> + AM_SDK_URL = " http : / / s3 . asia . ambiqmicro . com / downloads / AmbiqSuite - Rel2 . 0 . 0 . zip " <nl> AP3_URL = " https : / / github . com / AmbiqMicro / TFLiteMicro_Apollo3 / archive / dfbcef9a57276c087d95aab7cb234f1d4c9eaaba . zip " <nl> CUST_CMSIS_URL = " https : / / github . com / AmbiqMicro / TFLiteMicro_CustCMSIS / archive / 8f63966c5692e6a3a83956efd2e4aed77c4c9949 . zip " <nl> GCC_EMBEDDED_URL = " https : / / developer . arm . com / - / media / Files / downloads / gnu - rm / 7 - 2018q2 / gcc - arm - none - eabi - 7 - 2018 - q2 - update - linux . tar . bz2 " <nl> download_and_extract ( ) { <nl> find " $ { dir } " - type f - name ' * BUILD ' - delete <nl> } <nl> <nl> - patch_apollo3_sdk ( ) { <nl> - local ap3_dir = " $ { 1 } " <nl> - if [ ! - f $ { ap3_dir } / VERSION . txt ] ; then <nl> - echo " Could not find $ { ap3_dir } , skipping Apollo3 SDK " ; <nl> + patch_am_sdk ( ) { <nl> + local am_dir = " $ { 1 } " <nl> + if [ ! - f $ { am_dir } / VERSION . txt ] ; then <nl> + echo " Could not find $ { am_dir } , skipping AmbiqMicro SDK patch " ; <nl> return ; <nl> fi <nl> - local src_dir = $ { ap3_dir } / boards / apollo3_evb / examples / hello_world / gcc <nl> - local dest_dir = $ { ap3_dir } / boards / apollo3_evb / examples / hello_world / gcc_patched <nl> + <nl> + local src_dir = $ { am_dir } / boards / apollo3_evb / examples / hello_world / gcc <nl> + local dest_dir = $ { am_dir } / boards / apollo3_evb / examples / hello_world / gcc_patched <nl> + <nl> rm - rf $ { dest_dir } <nl> mkdir $ { dest_dir } <nl> + <nl> cp " $ { src_dir } / startup_gcc . c " " $ { dest_dir } / startup_gcc . c " <nl> cp " $ { src_dir } / hello_world . ld " " $ { dest_dir } / apollo3evb . ld " <nl> - sed - i - e ' 131s / 1024 / 1024 \ * 20 / g ' " $ { dest_dir } / startup_gcc . c " <nl> + <nl> + sed - i - e ' 114s / 1024 / 1024 \ * 20 / g ' " $ { dest_dir } / startup_gcc . c " <nl> sed - i - e ' s / main / _main / g ' " $ { dest_dir } / startup_gcc . c " <nl> + <nl> sed - i - e ' 3s / hello_world . ld / apollo3evb . ld / g ' " $ { dest_dir } / apollo3evb . ld " <nl> sed - i - e ' 3s / startup_gnu / startup_gcc / g ' " $ { dest_dir } / apollo3evb . ld " <nl> - sed - i - e ' 6s / am_reset_isr / Reset_Handler / g ' " $ { dest_dir } / apollo3evb . ld " <nl> sed - i - e ' 22s / \ * ( . text \ * ) / \ * ( . text \ * ) \ n \ n \ t \ / \ * These are the C + + global constructors . Stick them all here and \ n \ t \ * then walk through the array in main ( ) calling them all . \ n \ t \ * \ / \ n \ t_init_array_start = . ; \ n \ tKEEP ( \ * ( SORT ( . init_array \ * ) ) ) \ n \ t_init_array_end = . ; \ n \ n \ t \ / \ * XXX Currently not doing anything for global destructors . \ * \ / \ n / g ' " $ { dest_dir } / apollo3evb . ld " <nl> sed - i - e " 70s / } > SRAM / } > SRAM \ n \ / \ * Add this to satisfy reference to symbol ' end ' from libnosys . a ( sbrk . o ) \ n \ * to denote the HEAP start . \ n \ * \ / \ n end = . ; / g " " $ { dest_dir } / apollo3evb . ld " <nl> + <nl> echo " Finished preparing Apollo3 files " <nl> } <nl> <nl> download_and_extract " $ { CMSIS_URL } " " $ { DOWNLOADS_DIR } / cmsis " <nl> download_and_extract " $ { STM32_BARE_LIB_URL } " " $ { DOWNLOADS_DIR } / stm32_bare_lib " <nl> download_and_extract " $ { SIFIVE_FE310_LIB_URL } " " $ { DOWNLOADS_DIR } / sifive_fe310_lib " <nl> download_and_extract " $ { RISCV_TOOLCHAIN_URL } " " $ { DOWNLOADS_DIR } / riscv_toolchain " <nl> + download_and_extract " $ { AM_SDK_URL } " " $ { DOWNLOADS_DIR } / AmbiqSuite - Rel2 . 0 . 0 " <nl> + patch_am_sdk " $ { DOWNLOADS_DIR } / AmbiqSuite - Rel2 . 0 . 0 " <nl> download_and_extract " $ { AP3_URL } " " $ { DOWNLOADS_DIR } / apollo3_ext " <nl> - patch_apollo3_sdk " $ { DOWNLOADS_DIR } / Apollo3 - SDK - 2018 . 08 . 13 " <nl> download_and_extract " $ { CUST_CMSIS_URL } " " $ { DOWNLOADS_DIR } / CMSIS_ext " <nl> download_and_extract " $ { GCC_EMBEDDED_URL } " " $ { DOWNLOADS_DIR } / gcc_embedded " <nl> <nl> mmm a / tensorflow / lite / experimental / micro / tools / make / targets / apollo3evb_makefile . inc <nl> ppp b / tensorflow / lite / experimental / micro / tools / make / targets / apollo3evb_makefile . inc <nl> ifeq ( $ ( TARGET ) , apollo3evb ) <nl> TARGET_TOOLCHAIN_PREFIX : = arm - none - eabi - <nl> # Download the Ambiq Apollo3 SDK and set this variable to find the header <nl> # files : <nl> - APOLLO3_SDK : = $ ( MAKEFILE_DIR ) / downloads / Apollo3 - SDK - 2018 . 08 . 13 <nl> + APOLLO3_SDK : = $ ( MAKEFILE_DIR ) / downloads / AmbiqSuite - Rel2 . 0 . 0 <nl> # Need a pointer to the GNU ARM toolchain for crtbegin . o for the fp functions <nl> - # with the softfp interfaces . <nl> + # with the hard interfaces . <nl> GCC_ARM : = $ ( MAKEFILE_DIR ) / downloads / gcc_embedded / <nl> <nl> PLATFORM_FLAGS = \ <nl> ifeq ( $ ( TARGET ) , apollo3evb ) <nl> - mcpu = cortex - m4 \ <nl> - mthumb \ <nl> - mfpu = fpv4 - sp - d16 \ <nl> - - mfloat - abi = softfp \ <nl> + - mfloat - abi = hard \ <nl> - std = gnu + + 11 \ <nl> - Wvla \ <nl> - Wall \ <nl> ifeq ( $ ( TARGET ) , apollo3evb ) <nl> CXXFLAGS + = $ ( PLATFORM_FLAGS ) <nl> CCFLAGS + = $ ( PLATFORM_FLAGS ) <nl> LDFLAGS + = \ <nl> - - mthumb - mcpu = cortex - m4 - mfpu = fpv4 - sp - d16 - mfloat - abi = softfp \ <nl> + - mthumb - mcpu = cortex - m4 - mfpu = fpv4 - sp - d16 - mfloat - abi = hard \ <nl> - nostartfiles - static \ <nl> - Wl , - - gc - sections - Wl , - - entry , Reset_Handler \ <nl> - Wl , - - start - group - lm - lc - lgcc - Wl , - - end - group \ <nl> ifeq ( $ ( TARGET ) , apollo3evb ) <nl> MICROLITE_LIBS : = \ <nl> $ ( APOLLO3_SDK ) / boards / apollo3_evb / bsp / gcc / bin / libam_bsp . a \ <nl> $ ( APOLLO3_SDK ) / mcu / apollo3 / hal / gcc / bin / libam_hal . a \ <nl> - $ ( GCC_ARM ) / lib / gcc / arm - none - eabi / 7 . 3 . 1 / thumb / v7e - m / fpv4 - sp / softfp / crtbegin . o \ <nl> + $ ( GCC_ARM ) / lib / gcc / arm - none - eabi / 7 . 3 . 1 / thumb / v7e - m / fpv4 - sp / hard / crtbegin . o \ <nl> - lm <nl> INCLUDES + = \ <nl> - isystem $ ( MAKEFILE_DIR ) / downloads / cmsis / CMSIS / Core / Include / \ <nl> | Merge pull request from ashah - abq : master | tensorflow/tensorflow | 56ea633b8ee7203dd8d011dda29becf138a775c9 | 2019-02-12T01:58:15Z |
mmm a / modules / planning / scenarios / scenario_manager . cc <nl> ppp b / modules / planning / scenarios / scenario_manager . cc <nl> void ScenarioManager : : ScenarioDispatch ( const common : : TrajectoryPoint & ego_point , <nl> switch ( current_scenario_ - > scenario_type ( ) ) { <nl> case ScenarioConfig : : LANE_FOLLOW : <nl> case ScenarioConfig : : CHANGE_LANE : <nl> + break ; <nl> case ScenarioConfig : : SIDE_PASS : <nl> + / / for SIDE_PASS , need re - check <nl> + scenario_type = SelectSidePassScenario ( frame ) ; <nl> break ; <nl> case ScenarioConfig : : BARE_INTERSECTION_UNPROTECTED : <nl> case ScenarioConfig : : STOP_SIGN_PROTECTED : <nl> void ScenarioManager : : ScenarioDispatch ( const common : : TrajectoryPoint & ego_point , <nl> case ScenarioConfig : : TRAFFIC_LIGHT_PROTECTED : <nl> case ScenarioConfig : : TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN : <nl> case ScenarioConfig : : TRAFFIC_LIGHT_UNPROTECTED_RIGHT_TURN : <nl> + / / must continue until finish <nl> if ( current_scenario_ - > GetStatus ( ) ! = <nl> Scenario : : ScenarioStatus : : STATUS_DONE ) { <nl> scenario_type = current_scenario_ - > scenario_type ( ) ; <nl> | planning : fixed a bug in ScenarioDispatcher | ApolloAuto/apollo | 35f37dcc4a8b624bfc9c1f4726fc30b3b900f129 | 2019-04-04T22:37:44Z |
mmm a / . cicd / pipeline . yml <nl> ppp b / . cicd / pipeline . yml <nl> steps : <nl> - " buildkite - agent artifact upload generated - pipeline . yml " <nl> agents : <nl> queue : " automation - basic - builder - fleet " <nl> - timeout : $ { TIMEOUT : - 10 } <nl> + timeout : $ { TIMEOUT : - 10 } <nl> \ No newline at end of file <nl> | Remove newline . | EOSIO/eos | 804002c12c5afd534c10ee0f20109bbfc82a921a | 2019-09-13T13:59:05Z |
mmm a / osquery / events / tests / windows / usn_journal_reader_tests . cpp <nl> ppp b / osquery / events / tests / windows / usn_journal_reader_tests . cpp <nl> namespace osquery { <nl> class UsnJournalReaderTests : public testing : : Test { } ; <nl> <nl> TEST_F ( UsnJournalReaderTests , test_get_native_file_id ) { <nl> - USNFileReferenceNumber usn_file_ref = 0x00BBFF66 ; <nl> + USNFileReferenceNumber usn_file_ref { 0x00BBFF66 } ; <nl> FILE_ID_DESCRIPTOR file_id ; <nl> GetNativeFileIdFromUSNReference ( file_id , usn_file_ref ) ; <nl> ASSERT_TRUE ( file_id . Type = = ObjectIdType | | file_id . Type = = FileIdType ) ; <nl> mmm a / osquery / events / windows / ntfs_event_publisher . cpp <nl> ppp b / osquery / events / windows / ntfs_event_publisher . cpp <nl> Status NTFSEventPublisher : : run ( ) { <nl> } <nl> } <nl> <nl> - if ( old_name_record . node_ref_number ! = 0U ) { <nl> + if ( old_name_record . drive_letter ! = 0U ) { <nl> status = getPathFromParentFRN ( event . old_path , <nl> parent_frn_cache , <nl> old_name_record . drive_letter , <nl> mmm a / osquery / events / windows / usn_journal_reader . h <nl> ppp b / osquery / events / windows / usn_journal_reader . h <nl> struct USNFileReferenceNumber { <nl> std : : vector < std : : uint8_t > data ; <nl> <nl> USNFileReferenceNumber ( ) : data ( ) { } <nl> - USNFileReferenceNumber ( std : : uint64_t val ) { <nl> + explicit USNFileReferenceNumber ( std : : uint64_t val ) { <nl> data . resize ( sizeof ( val ) ) ; <nl> std : : memcpy ( data . data ( ) , & val , sizeof ( val ) ) ; <nl> } <nl> mmm a / osquery / tables / events / windows / ntfs_journal_events . cpp <nl> ppp b / osquery / tables / events / windows / ntfs_journal_events . cpp <nl> void processConfiguration ( const NTFSEventSubscriptionContextRef context , <nl> / / there ' s another TOCTOU here : another process could delete the file before <nl> / / we get its information . We don ' t want to lock the file , though , since it <nl> / / could be something imporant used by another process . <nl> - USNFileReferenceNumber frn = 0 ; <nl> + USNFileReferenceNumber frn { } ; <nl> <nl> # if _WIN32_WINNT > _WIN32_WINNT_WIN7 <nl> FILE_ID_INFO file_id_info ; <nl> | events / windows : Prevent overly eager old name record handling ( ) | osquery/osquery | 3f70f94b0aa718c6c6893343448070e1fc0e912d | 2020-01-31T14:34:44Z |
mmm a / torch / csrc / jit / tensorexpr / cuda_codegen . cpp <nl> ppp b / torch / csrc / jit / tensorexpr / cuda_codegen . cpp <nl> void CudaPrinter : : maybe_insert_sync ( ) { <nl> <nl> std : : string cudaDtypeCppString ( const Dtype & dtype ) { <nl> switch ( dtype . scalar_type ( ) ) { <nl> + case ScalarType : : Bool : <nl> + return " bool " ; <nl> case ScalarType : : Half : <nl> return " half " ; <nl> case ScalarType : : Char : <nl> std : : string cudaDtypeCppString ( const Dtype & dtype ) { <nl> return " short " ; <nl> case ScalarType : : Long : <nl> return " long " ; <nl> - default : ; / * nothing * / <nl> + default : <nl> + return dtype . ToCppString ( ) ; <nl> } <nl> - return dtype . ToCppString ( ) ; <nl> } <nl> <nl> static void print_flat_alloc ( std : : ostream & os , const Allocate * alloc ) { <nl> | [ TensorExpr ] Correctly print ' bool ' dtype in Cuda printer . ( ) | pytorch/pytorch | 0f60c8d878ed45264ab56c5a9922dba00c7e4707 | 2020-05-08T07:40:47Z |
mmm a / modules / tools / map_gen / map_gen_two_lanes_right_ext . py <nl> ppp b / modules / tools / map_gen / map_gen_two_lanes_right_ext . py <nl> <nl> <nl> from modules . map . proto import map_pb2 <nl> from modules . map . proto import map_lane_pb2 <nl> + from modules . map . proto import map_road_pb2 <nl> import math <nl> from shapely . geometry import LineString , Point <nl> <nl> def create_lane ( map , id ) : <nl> section . lane_id . add ( ) . id = str ( id ) <nl> section . lane_id . add ( ) . id = str ( id + 1000 ) <nl> <nl> + left_edge = section . boundary . outer_polygon . edge . add ( ) <nl> + left_edge . type = map_road_pb2 . BoundaryEdge . LEFT_BOUNDARY <nl> + left_edge_segment = left_edge . curve . segment . add ( ) <nl> + <nl> + right_edge = section . boundary . outer_polygon . edge . add ( ) <nl> + right_edge . type = map_road_pb2 . BoundaryEdge . RIGHT_BOUNDARY <nl> + right_edge_segment = right_edge . curve . segment . add ( ) <nl> + <nl> lane . right_neighbor_forward_lane_id . add ( ) . id = str ( id + 1000 ) <nl> lane_n1 . left_neighbor_forward_lane_id . add ( ) . id = str ( id ) <nl> <nl> if i > 0 : <nl> + right_edge_point = right_edge_segment . line_segment . point . add ( ) <nl> + left_edge_point = left_edge_segment . line_segment . point . add ( ) <nl> + <nl> left_bound_point = left_boundary . line_segment . point . add ( ) <nl> right_bound_point = right_boundary . line_segment . point . add ( ) <nl> central_point = central . line_segment . point . add ( ) <nl> def create_lane ( map , id ) : <nl> central_point . x = p . x <nl> central_point . y = p . y <nl> <nl> + left_edge_point . y = lp [ 1 ] <nl> + left_edge_point . x = lp [ 0 ] <nl> + <nl> left_sample = lane . left_sample . add ( ) <nl> left_sample . s = 0 <nl> left_sample . width = LANE_WIDTH / 2 . 0 <nl> def create_lane ( map , id ) : <nl> central_point . x = p . x <nl> central_point . y = p . y <nl> <nl> + right_edge_point . y = rp [ 1 ] <nl> + right_edge_point . x = rp [ 0 ] <nl> + <nl> left_sample = lane_n1 . left_sample . add ( ) <nl> left_sample . s = 0 <nl> left_sample . width = LANE_WIDTH / 2 . 0 <nl> def create_lane ( map , id ) : <nl> right_sample . s = 0 <nl> right_sample . width = LANE_WIDTH / 2 . 0 <nl> <nl> + right_edge_point = right_edge_segment . line_segment . point . add ( ) <nl> + left_edge_point = left_edge_segment . line_segment . point . add ( ) <nl> + <nl> left_bound_point = left_boundary . line_segment . point . add ( ) <nl> right_bound_point = right_boundary . line_segment . point . add ( ) <nl> central_point = central . line_segment . point . add ( ) <nl> def create_lane ( map , id ) : <nl> right_bound_point . y = rp [ 1 ] <nl> right_bound_point . x = rp [ 0 ] <nl> <nl> + left_edge_point . y = lp [ 1 ] <nl> + left_edge_point . x = lp [ 0 ] <nl> + <nl> left_sample = lane . left_sample . add ( ) <nl> left_sample . s = i % 100 + 1 <nl> left_sample . width = LANE_WIDTH / 2 . 0 <nl> def create_lane ( map , id ) : <nl> right_bound_point . y = rp [ 1 ] <nl> right_bound_point . x = rp [ 0 ] <nl> <nl> + right_edge_point . y = rp [ 1 ] <nl> + right_edge_point . x = rp [ 0 ] <nl> + <nl> left_sample = lane_n1 . left_sample . add ( ) <nl> left_sample . s = i % 100 + 1 <nl> left_sample . width = LANE_WIDTH / 2 . 0 <nl> | tools : added road boundary for 2 lanes map gen . | ApolloAuto/apollo | c590a916c20f9b914d870e4d54af4869c544cf39 | 2017-12-15T02:44:10Z |
mmm a / hphp / hack / src / server / dune <nl> ppp b / hphp / hack / src / server / dune <nl> <nl> ( libraries <nl> build <nl> ci_util <nl> + cgroup <nl> folly_stubs <nl> load_script <nl> lwt <nl> new file mode 100644 <nl> index 00000000000 . . 9a86b82c3ae <nl> mmm / dev / null <nl> ppp b / hphp / hack / src / utils / cgroup / cgroupProfiler . ml <nl> <nl> + module MemStats = struct <nl> + type memory_result = { <nl> + start : float ; <nl> + delta : float ; <nl> + high_water_mark_delta : float ; <nl> + } <nl> + <nl> + and running ' = { <nl> + running_groups_rev : string list ; <nl> + running_results : memory_result SMap . t SMap . t ; <nl> + running_sub_results_rev : finished list ; <nl> + } <nl> + <nl> + and running = running ' ref <nl> + <nl> + and finished = { <nl> + finished_label : string ; <nl> + finished_groups : string list ; <nl> + finished_results : memory_result SMap . t SMap . t ; <nl> + finished_sub_results : finished list ; <nl> + } <nl> + <nl> + let get_group_map ~ group running_memory = <nl> + match SMap . find_opt group ! running_memory . running_results with <nl> + | None - > <nl> + running_memory : = <nl> + { <nl> + ! running_memory with <nl> + running_groups_rev = group : : ! running_memory . running_groups_rev ; <nl> + running_results = <nl> + SMap . add group SMap . empty ! running_memory . running_results ; <nl> + } ; <nl> + SMap . empty <nl> + | Some group - > group <nl> + <nl> + let get_metric ~ group ~ metric running_memory = <nl> + get_group_map ~ group running_memory | > SMap . find_opt metric <nl> + <nl> + let set_metric ~ group ~ metric entry running_memory = <nl> + let group_map = <nl> + get_group_map ~ group running_memory | > SMap . add metric entry <nl> + in <nl> + running_memory : = <nl> + { <nl> + ! running_memory with <nl> + running_results = <nl> + SMap . add group group_map ! running_memory . running_results ; <nl> + } <nl> + <nl> + let start_sampling ~ group ~ metric ~ value running_memory = <nl> + let new_metric = <nl> + { start = value ; delta = 0 . 0 ; high_water_mark_delta = 0 . 0 } <nl> + in <nl> + set_metric ~ group ~ metric new_metric running_memory <nl> + <nl> + let sample_memory ~ group ~ metric ~ value running_memory = <nl> + match get_metric ~ group ~ metric running_memory with <nl> + | None - > start_sampling ~ group ~ metric ~ value running_memory <nl> + | Some old_metric - > <nl> + let new_metric = <nl> + { <nl> + old_metric with <nl> + delta = value - . old_metric . start ; <nl> + high_water_mark_delta = <nl> + max ( value - . old_metric . start ) old_metric . high_water_mark_delta ; <nl> + } <nl> + in <nl> + set_metric ~ group ~ metric new_metric running_memory <nl> + <nl> + let print_summary_memory_table = <nl> + let pretty_num f = <nl> + let abs_f = abs_float f in <nl> + if abs_f > 1000000000 . 0 then <nl> + Printf . sprintf " % + 7 . 2fG " ( f / . 1000000000 . 0 ) <nl> + else if abs_f > 1000000 . 0 then <nl> + Printf . sprintf " % + 7 . 2fM " ( f / . 1000000 . 0 ) <nl> + else if abs_f > 1000 . 0 then <nl> + Printf . sprintf " % + 7 . 2fK " ( f / . 1000 . 0 ) <nl> + else <nl> + Printf . sprintf " % + 7 . 2f " f <nl> + in <nl> + let pretty_pct num denom = <nl> + if denom = 0 . 0 then <nl> + " ( - - N / A - - ) " <nl> + else <nl> + let fraction = num / . denom in <nl> + if <nl> + fraction > = 10 . 0 <nl> + ( * e . g " ( + 20 . 4x ) " fits the space whereas ( + 2040 . 0 % ) doesn ' t * ) <nl> + then <nl> + Printf . sprintf " ( % + 6 . 1fx ) " fraction <nl> + else <nl> + Printf . sprintf " ( % + 6 . 1f % % ) " ( fraction * . 100 . 0 ) <nl> + in <nl> + ( * Prints a single row of the table . All but the last column have a fixed width . * ) <nl> + let print_summary_single ~ indent key result = <nl> + let indent = String . make indent ' ' in <nl> + Printf . eprintf <nl> + " % s % s % s % s % s % s % s \ n % ! " <nl> + ( pretty_num result . start ) <nl> + ( pretty_num result . delta ) <nl> + ( pretty_pct result . delta result . start ) <nl> + ( pretty_num result . high_water_mark_delta ) <nl> + ( pretty_pct result . high_water_mark_delta result . start ) <nl> + indent <nl> + key <nl> + in <nl> + let header_without_section = <nl> + " START DELTA HWM DELTA " <nl> + in <nl> + let pre_section_whitespace = <nl> + String . make ( String . length header_without_section ) ' ' <nl> + in <nl> + let print_group ~ indent finished_results group_name = <nl> + Base . Option . iter <nl> + ( SMap . find_opt group_name finished_results ) <nl> + ~ f : ( fun group - > <nl> + let indent_str = <nl> + String . make ( String . length header_without_section + indent - 2 ) ' ' <nl> + in <nl> + Printf . eprintf " % s = = % s = = \ n % ! " indent_str group_name ; <nl> + SMap . iter ( print_summary_single ~ indent : ( indent + 2 ) ) group ) <nl> + in <nl> + let print_header label = <nl> + let label = Printf . sprintf " % s Memory Stats " label in <nl> + let header = header_without_section ^ " SECTION " in <nl> + let header_len = String . length header + 8 in <nl> + let whitespace_len = header_len - String . length label in <nl> + Printf . eprintf <nl> + " % s % s % s \ n % ! " <nl> + ( String . make ( ( whitespace_len + 1 ) / 2 ) ' = ' ) <nl> + label <nl> + ( String . make ( whitespace_len / 2 ) ' = ' ) ; <nl> + Printf . eprintf " % s \ n % ! " header ; <nl> + Printf . eprintf " % s \ n % ! " ( String . make header_len ' - ' ) <nl> + in <nl> + let rec print_finished ~ indent results = <nl> + if <nl> + ( not ( SMap . is_empty results . finished_results ) ) <nl> + | | results . finished_sub_results < > [ ] <nl> + then ( <nl> + let header_indent = String . make indent ' = ' in <nl> + Printf . eprintf <nl> + " % s % s % s % s \ n % ! " <nl> + pre_section_whitespace <nl> + header_indent <nl> + results . finished_label <nl> + header_indent ; <nl> + let indent = indent + 2 in <nl> + List . iter <nl> + ( print_group ~ indent results . finished_results ) <nl> + results . finished_groups ; <nl> + List . iter <nl> + ( fun sub_result - > print_finished ~ indent sub_result ) <nl> + results . finished_sub_results <nl> + ) <nl> + in <nl> + fun memory - > <nl> + if <nl> + SMap . cardinal memory . finished_results > 0 <nl> + | | memory . finished_sub_results < > [ ] <nl> + then ( <nl> + print_header memory . finished_label ; <nl> + print_finished ~ indent : 2 memory <nl> + ) <nl> + end <nl> + <nl> + let sample_cgroup_mem group mem_stats = <nl> + let cgroup_stats = CGroup . get_stats ( ) in <nl> + match cgroup_stats with <nl> + | Error _ - > ( ) <nl> + | Ok { CGroup . total ; total_swap ; anon ; file ; shmem } - > <nl> + MemStats . sample_memory <nl> + mem_stats <nl> + ~ group <nl> + ~ metric : " cgroup_total " <nl> + ~ value : ( float total ) ; <nl> + MemStats . sample_memory <nl> + mem_stats <nl> + ~ group <nl> + ~ metric : " cgroup_swap " <nl> + ~ value : ( float total_swap ) ; <nl> + MemStats . sample_memory <nl> + mem_stats <nl> + ~ group <nl> + ~ metric : " cgroup_anon " <nl> + ~ value : ( float anon ) ; <nl> + MemStats . sample_memory <nl> + mem_stats <nl> + ~ group <nl> + ~ metric : " cgroup_shmem " <nl> + ~ value : ( float shmem ) ; <nl> + MemStats . sample_memory <nl> + mem_stats <nl> + ~ group <nl> + ~ metric : " cgroup_file " <nl> + ~ value : ( float file ) <nl> + <nl> + let collect_cgroup_stats mem_stats ~ group ~ f = <nl> + sample_cgroup_mem group mem_stats ; <nl> + let ret = f ( ) in <nl> + sample_cgroup_mem group mem_stats ; <nl> + ret <nl> + <nl> + let profile_memory ~ label ~ f = <nl> + let running_memory = <nl> + ref <nl> + MemStats . <nl> + { <nl> + running_groups_rev = [ ] ; <nl> + running_results = SMap . empty ; <nl> + running_sub_results_rev = [ ] ; <nl> + } <nl> + in <nl> + let ret = f running_memory in <nl> + let finished_memory = <nl> + MemStats . <nl> + { <nl> + finished_label = label ; <nl> + finished_groups = List . rev ! running_memory . running_groups_rev ; <nl> + finished_results = ! running_memory . running_results ; <nl> + finished_sub_results = List . rev ! running_memory . running_sub_results_rev ; <nl> + } <nl> + in <nl> + ( finished_memory , ret ) <nl> + <nl> + let print_summary_memory_table = MemStats . print_summary_memory_table <nl> new file mode 100644 <nl> index 00000000000 . . db5bac55a25 <nl> mmm / dev / null <nl> ppp b / hphp / hack / src / utils / cgroup / cgroupProfiler . mli <nl> <nl> + ( * <nl> + * Copyright ( c ) Facebook , Inc . and its affiliates . <nl> + * <nl> + * This source code is licensed under the MIT license found in the <nl> + * LICENSE file in the " hack " directory of this source tree . <nl> + * <nl> + * ) <nl> + <nl> + module MemStats : sig <nl> + type running <nl> + <nl> + type finished <nl> + <nl> + val sample_memory : <nl> + group : string - > metric : string - > value : float - > running - > unit <nl> + end <nl> + <nl> + val collect_cgroup_stats : <nl> + MemStats . running - > group : string - > f : ( unit - > ' a ) - > ' a <nl> + <nl> + val profile_memory : <nl> + label : string - > f : ( MemStats . running - > ' a ) - > MemStats . finished * ' a <nl> + <nl> + val print_summary_memory_table : MemStats . finished - > unit <nl> mmm a / hphp / hack / src / utils / cgroup / dune <nl> ppp b / hphp / hack / src / utils / cgroup / dune <nl> <nl> ( library <nl> ( name cgroup ) <nl> ( wrapped false ) <nl> + ( modules <nl> + CGroup <nl> + CgroupProfiler <nl> + ) <nl> ( libraries <nl> core_kernel <nl> lwt <nl> | add profiling module to sample cgroup memory stats | facebook/hhvm | c4b5ad6b591d4870a77ecc35d98f973def748af9 | 2020-10-27T00:38:37Z |
mmm a / tests / runner . py <nl> ppp b / tests / runner . py <nl> def test_reminder ( self ) : <nl> assert False , ' Why is libcxx / created in e . g . test_python , with EMCC_DEBUG , when it does not need libcxx ? ' <nl> assert False , ' Make sure Poppler builds with llvm full opts ' <nl> assert False , ' Check if we should use - Ox instead of - std - compile - opts ' <nl> + assert False , ' Make it easy to disable full llvm opts and use just normal ones ' <nl> <nl> elif ' benchmark ' in str ( sys . argv ) : <nl> # Benchmarks . Run them with argument | benchmark | . To run a specific test , do <nl> | reminder | emscripten-core/emscripten | 1c57629c24e0cda2ca23be2b886dae404adb8916 | 2012-01-27T17:55:19Z |
mmm a / tensorflow / compiler / mlir / xla / transforms / legalize_tf_with_tf2xla . cc <nl> ppp b / tensorflow / compiler / mlir / xla / transforms / legalize_tf_with_tf2xla . cc <nl> LogicalResult Tf2XlaRewriter : : PrepareParams ( ) { <nl> / / XlaCompiler within the context is only used by the functional ops to <nl> / / compile functions . We are not handling those at the moment so XlaCompiler <nl> / / is not required . <nl> - context_ = new tensorflow : : XlaContext ( / * compiler = * / nullptr , & hlo_builder_ ) ; <nl> + context_ = new tensorflow : : XlaContext ( / * compiler = * / nullptr , & hlo_builder_ , <nl> + / * graph = * / nullptr ) ; <nl> context_ - > Ref ( ) ; <nl> <nl> device_mgr_ = CreateDeviceMgr ( device_type_ ) ; <nl> mmm a / tensorflow / compiler / tf2xla / xla_compilation_device . cc <nl> ppp b / tensorflow / compiler / tf2xla / xla_compilation_device . cc <nl> Allocator * XlaCompilationDevice : : GetAllocator ( AllocatorAttributes attr ) { <nl> return allocator_ . get ( ) ; <nl> } <nl> <nl> + / / Attaches location from the node stack trace to metadata . As a heuristic , <nl> + / / picks the last frame which does not contain the " tensorflow / python " substring <nl> + / / ( making exception for frames containing " test " to allow for testing the <nl> + / / feature ) . <nl> + static void AttachLocationToMetadata ( xla : : OpMetadata & metadata , <nl> + OpKernel * op_kernel , XlaContext & context ) { <nl> + if ( const AbstractStackTrace * stack_trace = <nl> + context . StackTraceForNodeName ( op_kernel - > def ( ) . name ( ) ) ) { <nl> + if ( absl : : optional < StackFrame > frame = stack_trace - > LastUserFrame ( ) ) { <nl> + metadata . set_source_file ( frame - > file_name ) ; <nl> + metadata . set_source_line ( frame - > line_number ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> void XlaCompilationDevice : : Compute ( OpKernel * op_kernel , <nl> OpKernelContext * context ) { <nl> VLOG ( 4 ) < < " XlaCompilationDevice : : Compute " <nl> < < FormatNodeDefForError ( op_kernel - > def ( ) ) ; <nl> - auto * b = XlaContext : : Get ( context ) . builder ( ) ; <nl> + XlaContext & xla_context = XlaContext : : Get ( context ) ; <nl> + auto * b = xla_context . builder ( ) ; <nl> xla : : OpMetadata metadata ; <nl> metadata . set_op_type ( op_kernel - > type_string ( ) ) ; <nl> metadata . set_op_name ( op_kernel - > name ( ) ) ; <nl> + AttachLocationToMetadata ( metadata , op_kernel , xla_context ) ; <nl> b - > SetOpMetadata ( metadata ) ; <nl> <nl> auto sharding_parse_result = ParseShardingFromDevice ( <nl> mmm a / tensorflow / compiler / tf2xla / xla_compiler . cc <nl> ppp b / tensorflow / compiler / tf2xla / xla_compiler . cc <nl> Status XlaCompiler : : CompileGraph ( <nl> options_ . device_type , name ) ) ; <nl> <nl> xla : : XlaBuilder builder ( name ) ; <nl> - XlaContext * context = new XlaContext ( this , & builder ) ; <nl> + XlaContext * context = new XlaContext ( this , & builder , graph . get ( ) ) ; <nl> core : : ScopedUnref context_unref ( context ) ; <nl> <nl> std : : vector < XlaCompiler : : Argument > real_args ( args . begin ( ) , args . end ( ) ) ; <nl> mmm a / tensorflow / compiler / tf2xla / xla_context . cc <nl> ppp b / tensorflow / compiler / tf2xla / xla_context . cc <nl> void XlaContext : : set_args ( std : : vector < XlaExpression > args ) { <nl> args_ = std : : move ( args ) ; <nl> } <nl> <nl> - XlaContext : : XlaContext ( XlaCompiler * compiler , xla : : XlaBuilder * builder ) <nl> - : compiler_ ( compiler ) , builder_ ( builder ) { } <nl> + XlaContext : : XlaContext ( XlaCompiler * compiler , xla : : XlaBuilder * builder , <nl> + const Graph * graph ) <nl> + : compiler_ ( compiler ) , builder_ ( builder ) { <nl> + if ( graph ) { <nl> + for ( const Node * node : graph - > nodes ( ) ) { <nl> + stack_traces_ [ node - > name ( ) ] = node - > GetStackTrace ( ) ; <nl> + } <nl> + } <nl> + } <nl> <nl> string XlaContext : : DebugString ( ) const { return " XLA JIT context " ; } <nl> <nl> mmm a / tensorflow / compiler / tf2xla / xla_context . h <nl> ppp b / tensorflow / compiler / tf2xla / xla_context . h <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / xla_data . pb . h " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / resource_mgr . h " <nl> + # include " tensorflow / core / graph / graph . h " <nl> # include " tensorflow / core / platform / macros . h " <nl> <nl> namespace tensorflow { <nl> class XlaContext : public ResourceBase { <nl> <nl> / / Creates a new XlaContext . See the documentation on the class data fields <nl> / / for descriptions of the arguments . <nl> - XlaContext ( XlaCompiler * compiler , xla : : XlaBuilder * builder ) ; <nl> + XlaContext ( XlaCompiler * compiler , xla : : XlaBuilder * builder , <nl> + const Graph * graph ) ; <nl> <nl> / / Virtual method defined by ResourceBase . <nl> string DebugString ( ) const override ; <nl> <nl> XlaCompiler * compiler ( ) const { return compiler_ ; } <nl> <nl> + const AbstractStackTrace * StackTraceForNodeName ( const std : : string & name ) { <nl> + const auto & it = stack_traces_ . find ( name ) ; <nl> + if ( it ! = stack_traces_ . end ( ) ) { <nl> + return it - > second . get ( ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> / / Returns the XlaBuilder that Ops use for compiling new expressions . <nl> xla : : XlaBuilder * builder ( ) { return builder_ ; } <nl> <nl> class XlaContext : public ResourceBase { <nl> / / The XlaBuilder used to construct the subgraph ' s compiled representation . <nl> xla : : XlaBuilder * builder_ ; <nl> <nl> + / / Stack traces for the graph used for compilation . <nl> + StackTracesMap stack_traces_ ; <nl> + <nl> / / Arguments to the Tensorflow graph , indexed by _Arg index . <nl> / / Includes both compile - time constant arguments and runtime parameters . <nl> std : : vector < XlaExpression > args_ ; <nl> mmm a / tensorflow / core / common_runtime / inline_function_utils . cc <nl> ppp b / tensorflow / core / common_runtime / inline_function_utils . cc <nl> Status InlineFunctionBody ( const FunctionLibraryDefinition & flib_def , Graph * g , <nl> Node * clone = g - > AddNode ( ndef , & added_node ) ; <nl> TF_CHECK_OK ( added_node ) ; <nl> node_map [ n - > id ( ) ] = clone ; <nl> + clone - > SetStackTrace ( n - > GetStackTrace ( ) ) ; <nl> <nl> / / If there is an input control node , and one of : <nl> / / a ) the node has no data or control inputs , or <nl> mmm a / tensorflow / core / graph / graph . cc <nl> ppp b / tensorflow / core / graph / graph . cc <nl> Node * Graph : : CopyNode ( const Node * node ) { <nl> copy - > MaybeCopyOnWrite ( ) ; <nl> copy - > props_ - > op_def = op_def ; <nl> } <nl> + copy - > SetStackTrace ( node - > GetStackTrace ( ) ) ; <nl> <nl> return copy ; <nl> } <nl> mmm a / tensorflow / python / eager / def_function_xla_jit_test . py <nl> ppp b / tensorflow / python / eager / def_function_xla_jit_test . py <nl> def fn ( x ) : <nl> ' not compilable ' ) : <nl> xla_func ( inputs ) <nl> <nl> + @ test_util . disable_mlir_bridge ( ' TODO ( b / 155782411 ) : MLIR bridge does not ' <nl> + ' support stack traces ' ) <nl> + def testPythonLocationInMetadata ( self ) : <nl> + with ops . device ( ' device : { } : 0 ' . format ( self . device ) ) : <nl> + <nl> + @ def_function . function ( jit_compile = True ) <nl> + def fn ( x , y ) : <nl> + return x + y <nl> + <nl> + inputs = constant_op . constant ( [ 1 , 2 , 2 , 3 , 3 ] ) <nl> + self . assertIn ( ' def_function_xla_jit_test ' , <nl> + fn . experimental_get_compiler_ir ( inputs , inputs ) ( ) ) <nl> + <nl> + @ test_util . disable_mlir_bridge ( ' TODO ( b / 155782411 ) : MLIR bridge does not ' <nl> + ' support stack traces ' ) <nl> + def testPythonLocationNestedInMetadata ( self ) : <nl> + with ops . device ( ' device : { } : 0 ' . format ( self . device ) ) : <nl> + <nl> + @ def_function . function ( jit_compile = True ) <nl> + def f ( x , y ) : <nl> + return x + y <nl> + <nl> + @ def_function . function ( jit_compile = True ) <nl> + def g ( x , y ) : <nl> + return f ( x , y ) <nl> + <nl> + inputs = constant_op . constant ( [ 1 , 2 , 2 , 3 , 3 ] ) <nl> + self . assertIn ( ' def_function_xla_jit_test ' , <nl> + g . experimental_get_compiler_ir ( inputs , inputs ) ( ) ) <nl> + <nl> @ test_util . disable_mlir_bridge ( ' TODO ( b / 155782411 ) : MLIR bridge does not ' <nl> ' support stack traces ' ) <nl> def testPythonStackTrace ( self ) : <nl> mmm a / tensorflow / python / util / tf_stack . cc <nl> ppp b / tensorflow / python / util / tf_stack . cc <nl> class StackTraceWrapper : public AbstractStackTrace { <nl> void GenerateCache ( ) const { <nl> / / Grabbing the GIL solves two purposes : 1 ) makes the class thread - safe , and <nl> / / 2 ) ToStackFrames and LineContents actually need it . <nl> - PyGILState_STATE state = PyGILState_Ensure ( ) ; <nl> if ( stack_frames_cache_ ) { <nl> return ; <nl> } <nl> <nl> + PyGILState_STATE state = PyGILState_Ensure ( ) ; <nl> absl : : flat_hash_map < std : : pair < std : : string , int > , StackFrame > m ; <nl> absl : : flat_hash_set < std : : string > f ; <nl> <nl> | [ TF2XLA ] Display Python location information in XLA metadata | tensorflow/tensorflow | 29ebd644a2656bb37be716c5b8cd68b9c0c596be | 2020-12-11T00:53:44Z |
mmm a / . gitignore <nl> ppp b / . gitignore <nl> <nl> <nl> # Visual studio code <nl> . vscode <nl> + * . pdb <nl> + * . tlog <nl> + * . obj <nl> + * . pch <nl> + * . log <nl> + * . orig <nl> <nl> # Xcode <nl> # # Build generated <nl> mmm a / . hgignore <nl> ppp b / . hgignore <nl> <nl> <nl> # Visual studio code <nl> . vscode <nl> + * . pdb <nl> + * . tlog <nl> + * . obj <nl> + * . pch <nl> + * . log <nl> + * . orig <nl> <nl> # Xcode <nl> # # Build generated <nl> new file mode 100644 <nl> index 000000000 . . 27c15cf4c <nl> mmm / dev / null <nl> ppp b / csharp / Facebook . Yoga / Border . cs <nl> <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> + <nl> + namespace Facebook . Yoga <nl> + { <nl> + public class Border <nl> + { <nl> + public float ? Top ; <nl> + public float ? Bottom ; <nl> + public float ? Left ; <nl> + public float ? Right ; <nl> + <nl> + public Border ( <nl> + float ? top = null , <nl> + float ? bottom = null , <nl> + float ? left = null , <nl> + float ? right = null ) <nl> + { <nl> + Top = top ; <nl> + Bottom = bottom ; <nl> + Left = left ; <nl> + Right = right ; <nl> + } <nl> + } <nl> + } <nl> \ No newline at end of file <nl> mmm a / csharp / Facebook . Yoga / Native . cs <nl> ppp b / csharp / Facebook . Yoga / Native . cs <nl> protected override bool ReleaseHandle ( ) <nl> public static extern void YGNodeStyleSetFlexBasis ( YGNodeHandle node , float flexBasis ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetFlexBasis ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetFlexBasisPercent ( YGNodeHandle node , float flexBasis ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetFlexBasis ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetWidth ( YGNodeHandle node , float width ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetWidth ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetWidthPercent ( YGNodeHandle node , float width ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetWidth ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetHeight ( YGNodeHandle node , float height ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetHeight ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetHeightPercent ( YGNodeHandle node , float height ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetHeight ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetMinWidth ( YGNodeHandle node , float minWidth ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetMinWidth ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetMinWidthPercent ( YGNodeHandle node , float minWidth ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetMinWidth ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetMinHeight ( YGNodeHandle node , float minHeight ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetMinHeight ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetMinHeightPercent ( YGNodeHandle node , float minHeight ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetMinHeight ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetMaxWidth ( YGNodeHandle node , float maxWidth ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetMaxWidth ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetMaxWidthPercent ( YGNodeHandle node , float maxWidth ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetMaxWidth ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetMaxHeight ( YGNodeHandle node , float maxHeight ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetMaxHeight ( YGNodeHandle node ) ; <nl> + public static extern void YGNodeStyleSetMaxHeightPercent ( YGNodeHandle node , float maxHeight ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetMaxHeight ( YGNodeHandle node ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetAspectRatio ( YGNodeHandle node , float aspectRatio ) ; <nl> protected override bool ReleaseHandle ( ) <nl> public static extern void YGNodeStyleSetPosition ( YGNodeHandle node , YogaEdge edge , float position ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetPosition ( YGNodeHandle node , YogaEdge edge ) ; <nl> + public static extern void YGNodeStyleSetPositionPercent ( YGNodeHandle node , YogaEdge edge , float position ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetPosition ( YGNodeHandle node , YogaEdge edge ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetMargin ( YGNodeHandle node , YogaEdge edge , float margin ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetMargin ( YGNodeHandle node , YogaEdge edge ) ; <nl> + public static extern void YGNodeStyleSetMarginPercent ( YGNodeHandle node , YogaEdge edge , float margin ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetMargin ( YGNodeHandle node , YogaEdge edge ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetPadding ( YGNodeHandle node , YogaEdge edge , float padding ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> - public static extern float YGNodeStyleGetPadding ( YGNodeHandle node , YogaEdge edge ) ; <nl> + public static extern void YGNodeStyleSetPaddingPercent ( YGNodeHandle node , YogaEdge edge , float padding ) ; <nl> + <nl> + [ DllImport ( DllName ) ] <nl> + public static extern YogaValue YGNodeStyleGetPadding ( YGNodeHandle node , YogaEdge edge ) ; <nl> <nl> [ DllImport ( DllName ) ] <nl> public static extern void YGNodeStyleSetBorder ( YGNodeHandle node , YogaEdge edge , float border ) ; <nl> mmm a / csharp / Facebook . Yoga / Spacing . cs <nl> ppp b / csharp / Facebook . Yoga / Spacing . cs <nl> namespace Facebook . Yoga <nl> { <nl> public class Spacing <nl> { <nl> - public float ? Top ; <nl> - public float ? Bottom ; <nl> - public float ? Left ; <nl> - public float ? Right ; <nl> + public YogaValue ? Top ; <nl> + public YogaValue ? Bottom ; <nl> + public YogaValue ? Left ; <nl> + public YogaValue ? Right ; <nl> <nl> public Spacing ( <nl> - float ? top = null , <nl> - float ? bottom = null , <nl> - float ? left = null , <nl> - float ? right = null ) <nl> + YogaValue ? top = null , <nl> + YogaValue ? bottom = null , <nl> + YogaValue ? left = null , <nl> + YogaValue ? right = null ) <nl> { <nl> Top = top ; <nl> Bottom = bottom ; <nl> mmm a / csharp / Facebook . Yoga / YogaConstants . cs <nl> ppp b / csharp / Facebook . Yoga / YogaConstants . cs <nl> public static bool IsUndefined ( float value ) <nl> { <nl> return float . IsNaN ( value ) ; <nl> } <nl> + <nl> + public static bool IsUndefined ( YogaValue value ) <nl> + { <nl> + return value . Unit = = YogaUnit . Undefined ; <nl> + } <nl> } <nl> } <nl> mmm a / csharp / Facebook . Yoga / YogaNode . Create . cs <nl> ppp b / csharp / Facebook . Yoga / YogaNode . Create . cs <nl> public partial class YogaNode <nl> float ? flex = null , <nl> float ? flexGrow = null , <nl> float ? flexShrink = null , <nl> - float ? flexBasis = null , <nl> + YogaValue ? flexBasis = null , <nl> Spacing position = null , <nl> Spacing margin = null , <nl> Spacing padding = null , <nl> - Spacing border = null , <nl> - float ? width = null , <nl> - float ? height = null , <nl> - float ? maxWidth = null , <nl> - float ? maxHeight = null , <nl> - float ? minWidth = null , <nl> - float ? minHeight = null ) <nl> + Border border = null , <nl> + YogaValue ? width = null , <nl> + YogaValue ? height = null , <nl> + YogaValue ? maxWidth = null , <nl> + YogaValue ? maxHeight = null , <nl> + YogaValue ? minWidth = null , <nl> + YogaValue ? minHeight = null ) <nl> { <nl> YogaNode node = new YogaNode ( ) ; <nl> <nl> mmm a / csharp / Facebook . Yoga / YogaNode . cs <nl> ppp b / csharp / Facebook . Yoga / YogaNode . cs <nl> <nl> using System ; <nl> using System . Collections ; <nl> using System . Collections . Generic ; <nl> - using System . Runtime . InteropServices ; <nl> using System . Text ; <nl> <nl> namespace Facebook . Yoga <nl> public float FlexShrink <nl> } <nl> } <nl> <nl> - public float FlexBasis <nl> + public YogaValue FlexBasis <nl> { <nl> get <nl> { <nl> public float FlexBasis <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetFlexBasis ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetFlexBasisPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetFlexBasis ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float GetMargin ( YogaEdge edge ) <nl> + public YogaValue GetMargin ( YogaEdge edge ) <nl> { <nl> return Native . YGNodeStyleGetMargin ( _ygNode , edge ) ; <nl> } <nl> <nl> - public void SetMargin ( YogaEdge edge , float value ) <nl> + public void SetMargin ( YogaEdge edge , YogaValue value ) <nl> { <nl> - Native . YGNodeStyleSetMargin ( _ygNode , edge , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetMarginPercent ( _ygNode , edge , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetMargin ( _ygNode , edge , value . Value ) ; <nl> + } <nl> } <nl> <nl> - public float GetPadding ( YogaEdge edge ) <nl> + public YogaValue GetPadding ( YogaEdge edge ) <nl> { <nl> return Native . YGNodeStyleGetPadding ( _ygNode , edge ) ; <nl> } <nl> <nl> - public void SetPadding ( YogaEdge edge , float padding ) <nl> + public void SetPadding ( YogaEdge edge , YogaValue value ) <nl> { <nl> - Native . YGNodeStyleSetPadding ( _ygNode , edge , padding ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetPaddingPercent ( _ygNode , edge , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetPadding ( _ygNode , edge , value . Value ) ; <nl> + } <nl> } <nl> <nl> public float GetBorder ( YogaEdge edge ) <nl> public void SetBorder ( YogaEdge edge , float border ) <nl> Native . YGNodeStyleSetBorder ( _ygNode , edge , border ) ; <nl> } <nl> <nl> - public float GetPosition ( YogaEdge edge ) <nl> + public YogaValue GetPosition ( YogaEdge edge ) <nl> { <nl> return Native . YGNodeStyleGetPosition ( _ygNode , edge ) ; <nl> } <nl> <nl> - public void SetPosition ( YogaEdge edge , float position ) <nl> + public void SetPosition ( YogaEdge edge , YogaValue value ) <nl> { <nl> - Native . YGNodeStyleSetPosition ( _ygNode , edge , position ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetPositionPercent ( _ygNode , edge , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetPosition ( _ygNode , edge , value . Value ) ; <nl> + } <nl> } <nl> <nl> - public float Width <nl> + public YogaValue Width <nl> { <nl> get <nl> { <nl> public float Width <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetWidth ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetWidthPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetWidth ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float Height <nl> + public YogaValue Height <nl> { <nl> get <nl> { <nl> public float Height <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetHeight ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetHeightPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetHeight ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float MaxWidth <nl> + public YogaValue MaxWidth <nl> { <nl> get <nl> { <nl> public float MaxWidth <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetMaxWidth ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetMaxWidthPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetMaxWidth ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float MaxHeight <nl> + public YogaValue MaxHeight <nl> { <nl> get <nl> { <nl> public float MaxHeight <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetMaxHeight ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetMaxHeightPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetMaxHeight ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float MinWidth <nl> + public YogaValue MinWidth <nl> { <nl> get <nl> { <nl> public float MinWidth <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetMinWidth ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetMinWidthPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetMinWidth ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> - public float MinHeight <nl> + public YogaValue MinHeight <nl> { <nl> get <nl> { <nl> public float MinHeight <nl> <nl> set <nl> { <nl> - Native . YGNodeStyleSetMinHeight ( _ygNode , value ) ; <nl> + if ( value . Unit = = YogaUnit . Percent ) <nl> + { <nl> + Native . YGNodeStyleSetMinHeightPercent ( _ygNode , value . Value ) ; <nl> + } <nl> + else <nl> + { <nl> + Native . YGNodeStyleSetMinHeight ( _ygNode , value . Value ) ; <nl> + } <nl> } <nl> } <nl> <nl> new file mode 100644 <nl> index 000000000 . . 396c45dab <nl> mmm / dev / null <nl> ppp b / csharp / Facebook . Yoga / YogaUnit . cs <nl> <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> + <nl> + namespace Facebook . Yoga <nl> + { <nl> + public enum YogaUnit <nl> + { <nl> + Undefined , <nl> + Pixel , <nl> + Percent , <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 055f7d68a <nl> mmm / dev / null <nl> ppp b / csharp / Facebook . Yoga / YogaValue . cs <nl> <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> + <nl> + using System . Runtime . InteropServices ; <nl> + <nl> + namespace Facebook . Yoga <nl> + { <nl> + [ StructLayout ( LayoutKind . Sequential ) ] <nl> + public struct YogaValue <nl> + { <nl> + private float value ; <nl> + private YogaUnit unit ; <nl> + <nl> + public YogaUnit Unit = > unit ; <nl> + public float Value = > value ; <nl> + <nl> + public static YogaValue Pixel ( float value ) <nl> + { <nl> + return new YogaValue <nl> + { <nl> + value = value , <nl> + unit = YogaConstants . IsUndefined ( value ) ? YogaUnit . Undefined : YogaUnit . Pixel <nl> + } ; <nl> + } <nl> + <nl> + public bool Equals ( YogaValue other ) <nl> + { <nl> + return Unit = = other . Unit & & ( Value . Equals ( other . Value ) | | Unit = = YogaUnit . Undefined ) ; <nl> + } <nl> + <nl> + public override bool Equals ( object obj ) <nl> + { <nl> + if ( ReferenceEquals ( null , obj ) ) return false ; <nl> + return obj is YogaValue & & Equals ( ( YogaValue ) obj ) ; <nl> + } <nl> + <nl> + public override int GetHashCode ( ) <nl> + { <nl> + unchecked <nl> + { <nl> + return ( Value . GetHashCode ( ) * 397 ) ^ ( int ) Unit ; <nl> + } <nl> + } <nl> + <nl> + public static YogaValue Undefined ( ) <nl> + { <nl> + return new YogaValue <nl> + { <nl> + value = YogaConstants . Undefined , <nl> + unit = YogaUnit . Undefined <nl> + } ; <nl> + } <nl> + <nl> + public static YogaValue Percent ( float value ) <nl> + { <nl> + return new YogaValue <nl> + { <nl> + value = value , <nl> + unit = YogaConstants . IsUndefined ( value ) ? YogaUnit . Undefined : YogaUnit . Percent <nl> + } ; <nl> + } <nl> + <nl> + public static implicit operator YogaValue ( float pixelValue ) <nl> + { <nl> + return Pixel ( pixelValue ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 9ccee62a4 <nl> mmm / dev / null <nl> ppp b / csharp / Facebook . Yoga / YogaValueExtensions . cs <nl> <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> + <nl> + namespace Facebook . Yoga <nl> + { <nl> + public static class YogaValueExtensions <nl> + { <nl> + public static YogaValue Percent ( this float value ) <nl> + { <nl> + return YogaValue . Percent ( value ) ; <nl> + } <nl> + <nl> + public static YogaValue Px ( this float value ) <nl> + { <nl> + return YogaValue . Pixel ( value ) ; <nl> + } <nl> + <nl> + public static YogaValue Percent ( this int value ) <nl> + { <nl> + return YogaValue . Percent ( value ) ; <nl> + } <nl> + <nl> + public static YogaValue Px ( this int value ) <nl> + { <nl> + return YogaValue . Pixel ( value ) ; <nl> + } <nl> + } <nl> + } <nl> \ No newline at end of file <nl> mmm a / csharp / tests / Facebook . Yoga / YGAbsolutePositionTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGAbsolutePositionTest . cs <nl> public class YGAbsolutePositionTest <nl> public void Test_absolute_layout_width_height_start_top ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . Start , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Top , 10f ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . SetPosition ( YogaEdge . Start , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 10 ) ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_absolute_layout_width_height_start_top ( ) <nl> public void Test_absolute_layout_width_height_end_bottom ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . End , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Bottom , 10f ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . SetPosition ( YogaEdge . End , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Bottom , 10 ) ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_absolute_layout_width_height_end_bottom ( ) <nl> public void Test_absolute_layout_start_top_end_bottom ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . Start , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Top , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . End , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Bottom , 10f ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Start , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . End , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Bottom , 10 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_absolute_layout_start_top_end_bottom ( ) <nl> public void Test_absolute_layout_width_height_start_top_end_bottom ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . Start , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Top , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . End , 10f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Bottom , 10f ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . SetPosition ( YogaEdge . Start , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . End , 10 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Bottom , 10 ) ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_ <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . Overflow = YogaOverflow . Hidden ; <nl> - root . Width = 50f ; <nl> - root . Height = 50f ; <nl> + root . Width = 50 ; <nl> + root . Height = 50 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . Start , 0f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Top , 0f ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Start , 0 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 0 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . Width = 100f ; <nl> - root_child0_child0 . Height = 100f ; <nl> + root_child0_child0 . Width = 100 ; <nl> + root_child0_child0 . Height = 100 ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_ <nl> public void Test_absolute_layout_within_border ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetMargin ( YogaEdge . Left , 10f ) ; <nl> - root . SetMargin ( YogaEdge . Top , 10f ) ; <nl> - root . SetMargin ( YogaEdge . Right , 10f ) ; <nl> - root . SetMargin ( YogaEdge . Bottom , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Left , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Top , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Right , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Left , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Top , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Right , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 10f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetMargin ( YogaEdge . Left , 10 ) ; <nl> + root . SetMargin ( YogaEdge . Top , 10 ) ; <nl> + root . SetMargin ( YogaEdge . Right , 10 ) ; <nl> + root . SetMargin ( YogaEdge . Bottom , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Left , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Top , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Right , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Left , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Top , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Right , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 10 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . PositionType = YogaPositionType . Absolute ; <nl> - root_child0 . SetPosition ( YogaEdge . Left , 0f ) ; <nl> - root_child0 . SetPosition ( YogaEdge . Top , 0f ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 50f ; <nl> + root_child0 . SetPosition ( YogaEdge . Left , 0 ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 0 ) ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> root_child1 . PositionType = YogaPositionType . Absolute ; <nl> - root_child1 . SetPosition ( YogaEdge . Right , 0f ) ; <nl> - root_child1 . SetPosition ( YogaEdge . Bottom , 0f ) ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 50f ; <nl> + root_child1 . SetPosition ( YogaEdge . Right , 0 ) ; <nl> + root_child1 . SetPosition ( YogaEdge . Bottom , 0 ) ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGAlignContentTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGAlignContentTest . cs <nl> public void Test_align_content_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Width = 50 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 50f ; <nl> - root_child3 . Height = 10f ; <nl> + root_child3 . Width = 50 ; <nl> + root_child3 . Height = 10 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> <nl> YogaNode root_child4 = new YogaNode ( ) ; <nl> - root_child4 . Width = 50f ; <nl> - root_child4 . Height = 10f ; <nl> + root_child4 . Width = 50 ; <nl> + root_child4 . Height = 10 ; <nl> root . Insert ( 4 , root_child4 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_content_flex_end ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignContent = YogaAlign . FlexEnd ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Width = 50 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 50f ; <nl> - root_child3 . Height = 10f ; <nl> + root_child3 . Width = 50 ; <nl> + root_child3 . Height = 10 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> <nl> YogaNode root_child4 = new YogaNode ( ) ; <nl> - root_child4 . Width = 50f ; <nl> - root_child4 . Height = 10f ; <nl> + root_child4 . Width = 50 ; <nl> + root_child4 . Height = 10 ; <nl> root . Insert ( 4 , root_child4 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_content_center ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignContent = YogaAlign . Center ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Width = 50 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 50f ; <nl> - root_child3 . Height = 10f ; <nl> + root_child3 . Width = 50 ; <nl> + root_child3 . Height = 10 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> <nl> YogaNode root_child4 = new YogaNode ( ) ; <nl> - root_child4 . Width = 50f ; <nl> - root_child4 . Height = 10f ; <nl> + root_child4 . Width = 50 ; <nl> + root_child4 . Height = 10 ; <nl> root . Insert ( 4 , root_child4 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_content_stretch ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignContent = YogaAlign . Stretch ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> + root_child0 . Width = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> + root_child1 . Width = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> + root_child2 . Width = 50 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 50f ; <nl> + root_child3 . Width = 50 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> <nl> YogaNode root_child4 = new YogaNode ( ) ; <nl> - root_child4 . Width = 50f ; <nl> + root_child4 . Width = 50 ; <nl> root . Insert ( 4 , root_child4 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGAlignItemsTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGAlignItemsTest . cs <nl> public class YGAlignItemsTest <nl> public void Test_align_items_stretch ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_items_center ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignItems = YogaAlign . Center ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_items_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignItems = YogaAlign . FlexStart ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_items_flex_end ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignItems = YogaAlign . FlexEnd ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGAlignSelfTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGAlignSelfTest . cs <nl> public class YGAlignSelfTest <nl> public void Test_align_self_center ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . AlignSelf = YogaAlign . Center ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_self_center ( ) <nl> public void Test_align_self_flex_end ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . AlignSelf = YogaAlign . FlexEnd ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_self_flex_end ( ) <nl> public void Test_align_self_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . AlignSelf = YogaAlign . FlexStart ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_self_flex_end_override_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignItems = YogaAlign . FlexStart ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . AlignSelf = YogaAlign . FlexEnd ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGBorderTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGBorderTest . cs <nl> public class YGBorderTest <nl> public void Test_border_no_size ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetBorder ( YogaEdge . Left , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Top , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Right , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 10f ) ; <nl> + root . SetBorder ( YogaEdge . Left , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Top , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Right , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 10 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> <nl> public void Test_border_no_size ( ) <nl> public void Test_border_container_match_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetBorder ( YogaEdge . Left , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Top , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Right , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 10f ) ; <nl> + root . SetBorder ( YogaEdge . Left , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Top , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Right , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 10 ) ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_border_container_match_child ( ) <nl> public void Test_border_flex_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetBorder ( YogaEdge . Left , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Top , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Right , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 10f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetBorder ( YogaEdge . Left , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Top , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Right , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 10 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_border_flex_child ( ) <nl> public void Test_border_stretch_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetBorder ( YogaEdge . Left , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Top , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Right , 10f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 10f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetBorder ( YogaEdge . Left , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Top , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Right , 10 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 10 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_border_center_child ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> root . AlignItems = YogaAlign . Center ; <nl> - root . SetBorder ( YogaEdge . Start , 10f ) ; <nl> - root . SetBorder ( YogaEdge . End , 20f ) ; <nl> - root . SetBorder ( YogaEdge . Bottom , 20f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetBorder ( YogaEdge . Start , 10 ) ; <nl> + root . SetBorder ( YogaEdge . End , 20 ) ; <nl> + root . SetBorder ( YogaEdge . Bottom , 20 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGFlexDirectionTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGFlexDirectionTest . cs <nl> public class YGFlexDirectionTest <nl> public void Test_flex_direction_column_no_height ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_direction_row_no_width ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Height = 100f ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_direction_row_no_width ( ) <nl> public void Test_flex_direction_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_direction_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_direction_column_reverse ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . ColumnReverse ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_direction_row_reverse ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . RowReverse ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGFlexTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGFlexTest . cs <nl> public class YGFlexTest <nl> public void Test_flex_basis_flex_grow_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_basis_flex_grow_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_basis_flex_grow_row ( ) <nl> public void Test_flex_basis_flex_shrink_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexShrink = 1f ; <nl> - root_child0 . FlexBasis = 100f ; <nl> + root_child0 . FlexShrink = 1 ; <nl> + root_child0 . FlexBasis = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexBasis = 50f ; <nl> + root_child1 . FlexBasis = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_basis_flex_shrink_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexShrink = 1f ; <nl> - root_child0 . FlexBasis = 100f ; <nl> + root_child0 . FlexShrink = 1 ; <nl> + root_child0 . FlexBasis = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexBasis = 50f ; <nl> + root_child1 . FlexBasis = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_basis_flex_shrink_row ( ) <nl> public void Test_flex_shrink_to_zero ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Height = 75f ; <nl> + root . Height = 75 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 50f ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexShrink = 1f ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 50f ; <nl> + root_child1 . FlexShrink = 1 ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> - root_child2 . Height = 50f ; <nl> + root_child2 . Width = 50 ; <nl> + root_child2 . Height = 50 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_shrink_to_zero ( ) <nl> public void Test_flex_basis_overrides_main_size ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_basis_overrides_main_size ( ) <nl> public void Test_flex_grow_shrink_at_most ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . FlexGrow = 1f ; <nl> - root_child0_child0 . FlexShrink = 1f ; <nl> + root_child0_child0 . FlexGrow = 1 ; <nl> + root_child0_child0 . FlexShrink = 1 ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGFlexWrapTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGFlexWrapTest . cs <nl> public void Test_wrap_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Height = 100f ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 30f ; <nl> - root_child0 . Height = 30f ; <nl> + root_child0 . Width = 30 ; <nl> + root_child0 . Height = 30 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 30f ; <nl> - root_child1 . Height = 30f ; <nl> + root_child1 . Width = 30 ; <nl> + root_child1 . Height = 30 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 30f ; <nl> - root_child2 . Height = 30f ; <nl> + root_child2 . Width = 30 ; <nl> + root_child2 . Height = 30 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 30f ; <nl> - root_child3 . Height = 30f ; <nl> + root_child3 . Width = 30 ; <nl> + root_child3 . Height = 30 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_wrap_row ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 30f ; <nl> - root_child0 . Height = 30f ; <nl> + root_child0 . Width = 30 ; <nl> + root_child0 . Height = 30 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 30f ; <nl> - root_child1 . Height = 30f ; <nl> + root_child1 . Width = 30 ; <nl> + root_child1 . Height = 30 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 30f ; <nl> - root_child2 . Height = 30f ; <nl> + root_child2 . Width = 30 ; <nl> + root_child2 . Height = 30 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 30f ; <nl> - root_child3 . Height = 30f ; <nl> + root_child3 . Width = 30 ; <nl> + root_child3 . Height = 30 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_wrap_row_align_items_flex_end ( ) <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . AlignItems = YogaAlign . FlexEnd ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 30f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 30 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 30f ; <nl> - root_child1 . Height = 20f ; <nl> + root_child1 . Width = 30 ; <nl> + root_child1 . Height = 20 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 30f ; <nl> - root_child2 . Height = 30f ; <nl> + root_child2 . Width = 30 ; <nl> + root_child2 . Height = 30 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 30f ; <nl> - root_child3 . Height = 30f ; <nl> + root_child3 . Width = 30 ; <nl> + root_child3 . Height = 30 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_wrap_row_align_items_center ( ) <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . AlignItems = YogaAlign . Center ; <nl> root . Wrap = YogaWrap . Wrap ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 30f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 30 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 30f ; <nl> - root_child1 . Height = 20f ; <nl> + root_child1 . Width = 30 ; <nl> + root_child1 . Height = 20 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 30f ; <nl> - root_child2 . Height = 30f ; <nl> + root_child2 . Width = 30 ; <nl> + root_child2 . Height = 30 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . Width = 30f ; <nl> - root_child3 . Height = 30f ; <nl> + root_child3 . Width = 30 ; <nl> + root_child3 . Height = 30 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGJustifyContentTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGJustifyContentTest . cs <nl> public void Test_justify_content_row_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_row_flex_end ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . JustifyContent = YogaJustify . FlexEnd ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_row_center ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_row_space_between ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . JustifyContent = YogaJustify . SpaceBetween ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_row_space_around ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . JustifyContent = YogaJustify . SpaceAround ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 10f ; <nl> + root_child1 . Width = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 10f ; <nl> + root_child2 . Width = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_row_space_around ( ) <nl> public void Test_justify_content_column_flex_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_column_flex_end ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . FlexEnd ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_column_center ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_column_space_between ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . SpaceBetween ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_column_space_around ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . SpaceAround ; <nl> - root . Width = 102f ; <nl> - root . Height = 102f ; <nl> + root . Width = 102 ; <nl> + root . Height = 102 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGMarginTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGMarginTest . cs <nl> public void Test_margin_start ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . SetMargin ( YogaEdge . Start , 10f ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . SetMargin ( YogaEdge . Start , 10 ) ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_start ( ) <nl> public void Test_margin_top ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . SetMargin ( YogaEdge . Top , 10f ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . SetMargin ( YogaEdge . Top , 10 ) ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_end ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> root . JustifyContent = YogaJustify . FlexEnd ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . SetMargin ( YogaEdge . End , 10f ) ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . SetMargin ( YogaEdge . End , 10 ) ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_bottom ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . FlexEnd ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . SetMargin ( YogaEdge . Bottom , 10f ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . SetMargin ( YogaEdge . Bottom , 10 ) ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_and_flex_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . SetMargin ( YogaEdge . Start , 10f ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetMargin ( YogaEdge . Start , 10 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_and_flex_row ( ) <nl> public void Test_margin_and_flex_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . SetMargin ( YogaEdge . Top , 10f ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetMargin ( YogaEdge . Top , 10 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_and_stretch_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . SetMargin ( YogaEdge . Top , 10f ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetMargin ( YogaEdge . Top , 10 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_and_stretch_row ( ) <nl> public void Test_margin_and_stretch_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . SetMargin ( YogaEdge . Start , 10f ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetMargin ( YogaEdge . Start , 10 ) ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_with_sibling_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_margin_with_sibling_row ( ) <nl> public void Test_margin_with_sibling_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGMinMaxDimensionTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGMinMaxDimensionTest . cs <nl> public class YGMinMaxDimensionTest <nl> public void Test_max_width ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . MaxWidth = 50f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . MaxWidth = 50 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_max_height ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . MaxHeight = 50f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . MaxHeight = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_max_height ( ) <nl> public void Test_min_height ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . MinHeight = 60f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . MinHeight = 60 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_min_width ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . MinWidth = 60f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . MinWidth = 60 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_min_max ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> - root . Width = 100f ; <nl> - root . MinHeight = 100f ; <nl> - root . MaxHeight = 200f ; <nl> + root . Width = 100 ; <nl> + root . MinHeight = 100 ; <nl> + root . MaxHeight = 200 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 60f ; <nl> - root_child0 . Height = 60f ; <nl> + root_child0 . Width = 60 ; <nl> + root_child0 . Height = 60 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_align_items_min_max ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . AlignItems = YogaAlign . Center ; <nl> - root . MinWidth = 100f ; <nl> - root . MaxWidth = 200f ; <nl> - root . Height = 100f ; <nl> + root . MinWidth = 100 ; <nl> + root . MaxWidth = 200 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 60f ; <nl> - root_child0 . Height = 60f ; <nl> + root_child0 . Width = 60 ; <nl> + root_child0 . Height = 60 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_overflow_min_max ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> - root . MinHeight = 100f ; <nl> - root . MaxHeight = 110f ; <nl> + root . MinHeight = 100 ; <nl> + root . MaxHeight = 110 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 50f ; <nl> - root_child0 . Height = 50f ; <nl> + root_child0 . Width = 50 ; <nl> + root_child0 . Height = 50 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> - root_child1 . Height = 50f ; <nl> + root_child1 . Width = 50 ; <nl> + root_child1 . Height = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . Width = 50f ; <nl> - root_child2 . Height = 50f ; <nl> + root_child2 . Width = 50 ; <nl> + root_child2 . Height = 50 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_justify_content_overflow_min_max ( ) <nl> public void Test_flex_grow_within_max_width ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 200f ; <nl> - root . Height = 100f ; <nl> + root . Width = 200 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . FlexDirection = YogaFlexDirection . Row ; <nl> - root_child0 . MaxWidth = 100f ; <nl> + root_child0 . MaxWidth = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . FlexGrow = 1f ; <nl> - root_child0_child0 . Height = 20f ; <nl> + root_child0_child0 . FlexGrow = 1 ; <nl> + root_child0_child0 . Height = 20 ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_grow_within_max_width ( ) <nl> public void Test_flex_grow_within_constrained_max_width ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 200f ; <nl> - root . Height = 100f ; <nl> + root . Width = 200 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . FlexDirection = YogaFlexDirection . Row ; <nl> - root_child0 . MaxWidth = 300f ; <nl> + root_child0 . MaxWidth = 300 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . FlexGrow = 1f ; <nl> - root_child0_child0 . Height = 20f ; <nl> + root_child0_child0 . FlexGrow = 1 ; <nl> + root_child0_child0 . Height = 20 ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_grow_within_constrained_min_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . MinWidth = 100f ; <nl> - root . Height = 100f ; <nl> + root . MinWidth = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Width = 50f ; <nl> + root_child1 . Width = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_grow_within_constrained_min_row ( ) <nl> public void Test_flex_grow_within_constrained_min_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . MinHeight = 100f ; <nl> + root . MinHeight = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 50f ; <nl> + root_child1 . Height = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_grow_within_constrained_min_column ( ) <nl> public void Test_flex_grow_within_constrained_max_row ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 200f ; <nl> + root . Width = 200 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> root_child0 . FlexDirection = YogaFlexDirection . Row ; <nl> - root_child0 . MaxWidth = 100f ; <nl> - root_child0 . Height = 100f ; <nl> + root_child0 . MaxWidth = 100 ; <nl> + root_child0 . Height = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . FlexShrink = 1f ; <nl> - root_child0_child0 . FlexBasis = 100f ; <nl> + root_child0_child0 . FlexShrink = 1 ; <nl> + root_child0_child0 . FlexBasis = 100 ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> <nl> YogaNode root_child0_child1 = new YogaNode ( ) ; <nl> - root_child0_child1 . Width = 50f ; <nl> + root_child0_child1 . Width = 50 ; <nl> root_child0 . Insert ( 1 , root_child0_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_flex_grow_within_constrained_max_row ( ) <nl> public void Test_flex_grow_within_constrained_max_column ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . MaxHeight = 100f ; <nl> + root . Width = 100 ; <nl> + root . MaxHeight = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexShrink = 1f ; <nl> - root_child0 . FlexBasis = 100f ; <nl> + root_child0 . FlexShrink = 1 ; <nl> + root_child0 . FlexBasis = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . Height = 50f ; <nl> + root_child1 . Height = 50 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YGPaddingTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGPaddingTest . cs <nl> public class YGPaddingTest <nl> public void Test_padding_no_size ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetPadding ( YogaEdge . Left , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Top , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Right , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 10f ) ; <nl> + root . SetPadding ( YogaEdge . Left , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Top , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Right , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 10 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> <nl> public void Test_padding_no_size ( ) <nl> public void Test_padding_container_match_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetPadding ( YogaEdge . Left , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Top , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Right , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 10f ) ; <nl> + root . SetPadding ( YogaEdge . Left , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Top , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Right , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 10 ) ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_padding_container_match_child ( ) <nl> public void Test_padding_flex_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetPadding ( YogaEdge . Left , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Top , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Right , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 10f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetPadding ( YogaEdge . Left , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Top , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Right , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 10 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . Width = 10f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . Width = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_padding_flex_child ( ) <nl> public void Test_padding_stretch_child ( ) <nl> { <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . SetPadding ( YogaEdge . Left , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Top , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Right , 10f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 10f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetPadding ( YogaEdge . Left , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Top , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Right , 10 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 10 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_padding_center_child ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . Center ; <nl> root . AlignItems = YogaAlign . Center ; <nl> - root . SetPadding ( YogaEdge . Start , 10f ) ; <nl> - root . SetPadding ( YogaEdge . End , 20f ) ; <nl> - root . SetPadding ( YogaEdge . Bottom , 20f ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . SetPadding ( YogaEdge . Start , 10 ) ; <nl> + root . SetPadding ( YogaEdge . End , 20 ) ; <nl> + root . SetPadding ( YogaEdge . Bottom , 20 ) ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . Width = 10f ; <nl> - root_child0 . Height = 10f ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_child_with_padding_align_end ( ) <nl> YogaNode root = new YogaNode ( ) ; <nl> root . JustifyContent = YogaJustify . FlexEnd ; <nl> root . AlignItems = YogaAlign . FlexEnd ; <nl> - root . Width = 200f ; <nl> - root . Height = 200f ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . SetPadding ( YogaEdge . Left , 20f ) ; <nl> - root_child0 . SetPadding ( YogaEdge . Top , 20f ) ; <nl> - root_child0 . SetPadding ( YogaEdge . Right , 20f ) ; <nl> - root_child0 . SetPadding ( YogaEdge . Bottom , 20f ) ; <nl> - root_child0 . Width = 100f ; <nl> - root_child0 . Height = 100f ; <nl> + root_child0 . SetPadding ( YogaEdge . Left , 20 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Top , 20 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Right , 20 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Bottom , 20 ) ; <nl> + root_child0 . Width = 100 ; <nl> + root_child0 . Height = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> new file mode 100644 <nl> index 000000000 . . 7c9bc4237 <nl> mmm / dev / null <nl> ppp b / csharp / tests / Facebook . Yoga / YGPercentageTest . cs <nl> <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> + <nl> + / / @ Generated by gentest / gentest . rb from gentest / fixtures / YGPercentageTest . html <nl> + <nl> + using System ; <nl> + using NUnit . Framework ; <nl> + <nl> + namespace Facebook . Yoga <nl> + { <nl> + [ TestFixture ] <nl> + public class YGPercentageTest <nl> + { <nl> + [ Test ] <nl> + public void Test_percentage_width_height ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . Width = 30 . Percent ( ) ; <nl> + root_child0 . Height = 30 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 140f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_position_left_top ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 400 ; <nl> + root . Height = 400 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Left , 10 . Percent ( ) ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 20 . Percent ( ) ) ; <nl> + root_child0 . Width = 45 . Percent ( ) ; <nl> + root_child0 . Height = 55 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 400f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 400f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 40f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 80f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 180f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 220f , root_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 400f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 400f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 260f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 80f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 180f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 220f , root_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_position_bottom_right ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 500 ; <nl> + root . Height = 500 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Right , 20 . Percent ( ) ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Bottom , 10 . Percent ( ) ) ; <nl> + root_child0 . Width = 55 . Percent ( ) ; <nl> + root_child0 . Height = 15 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 500f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 500f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( - 100f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( - 50f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 275f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 75f , root_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 500f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 500f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 125f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( - 50f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 275f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 75f , root_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . FlexBasis = 25 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 125f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 125f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 75f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 75f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 125f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 75f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_cross ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . FlexBasis = 25 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 125f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 125f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 75f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 125f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 125f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 75f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_cross_min_height ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . MinHeight = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 2 ; <nl> + root_child1 . MinHeight = 10 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 140f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 140f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 140f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 140f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_main_max_height ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child0 . MaxHeight = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child1 . MaxHeight = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 52f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 52f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 148f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 148f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 52f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 148f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_cross_max_height ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child0 . MaxHeight = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child1 . MaxHeight = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 120f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 120f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_main_max_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 15 . Percent ( ) ; <nl> + root_child0 . MaxWidth = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child1 . MaxWidth = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 120f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 80f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_cross_max_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child0 . MaxWidth = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 15 . Percent ( ) ; <nl> + root_child1 . MaxWidth = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 50f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 50f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 150f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 80f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 50f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 160f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 50f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 40f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 150f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_main_min_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . FlexDirection = YogaFlexDirection . Row ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 15 . Percent ( ) ; <nl> + root_child0 . MinWidth = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child1 . MinWidth = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 120f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 80f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 80f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 120f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 80f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_flex_basis_cross_min_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child0 . MinWidth = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 15 . Percent ( ) ; <nl> + root_child1 . MinWidth = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 50f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 50f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 150f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 50f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 50f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 150f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 200 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 10 . Percent ( ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Left , 5 ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Top , 5 ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Right , 5 ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Bottom , 5 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Left , 3 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Top , 3 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Right , 3 ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Bottom , 3 ) ; <nl> + root_child0 . MinWidth = 60 . Percent ( ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . SetMargin ( YogaEdge . Left , 5 ) ; <nl> + root_child0_child0 . SetMargin ( YogaEdge . Top , 5 ) ; <nl> + root_child0_child0 . SetMargin ( YogaEdge . Right , 5 ) ; <nl> + root_child0_child0 . SetMargin ( YogaEdge . Bottom , 5 ) ; <nl> + root_child0_child0 . SetPadding ( YogaEdge . Left , 3 . Percent ( ) ) ; <nl> + root_child0_child0 . SetPadding ( YogaEdge . Top , 3 . Percent ( ) ) ; <nl> + root_child0_child0 . SetPadding ( YogaEdge . Right , 3 . Percent ( ) ) ; <nl> + root_child0_child0 . SetPadding ( YogaEdge . Bottom , 3 . Percent ( ) ) ; <nl> + root_child0_child0 . Width = 50 . Percent ( ) ; <nl> + root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> + <nl> + YogaNode root_child0_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0_child0 . SetMargin ( YogaEdge . Left , 5 . Percent ( ) ) ; <nl> + root_child0_child0_child0 . SetMargin ( YogaEdge . Top , 5 . Percent ( ) ) ; <nl> + root_child0_child0_child0 . SetMargin ( YogaEdge . Right , 5 . Percent ( ) ) ; <nl> + root_child0_child0_child0 . SetMargin ( YogaEdge . Bottom , 5 . Percent ( ) ) ; <nl> + root_child0_child0_child0 . SetPadding ( YogaEdge . Left , 3 ) ; <nl> + root_child0_child0_child0 . SetPadding ( YogaEdge . Top , 3 ) ; <nl> + root_child0_child0_child0 . SetPadding ( YogaEdge . Right , 3 ) ; <nl> + root_child0_child0_child0 . SetPadding ( YogaEdge . Bottom , 3 ) ; <nl> + root_child0_child0_child0 . Width = 45 . Percent ( ) ; <nl> + root_child0_child0 . Insert ( 0 , root_child0_child0_child0 ) ; <nl> + <nl> + YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . FlexGrow = 4 ; <nl> + root_child1 . FlexBasis = 15 . Percent ( ) ; <nl> + root_child1 . MinWidth = 20 . Percent ( ) ; <nl> + root . Insert ( 1 , root_child1 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 5f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 5f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 190f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 48f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 8f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 8f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 92f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 25f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 10f , root_child0_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 36f , root_child0_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 6f , root_child0_child0_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 58f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 142f , root_child1 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 5f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 5f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 190f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 48f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 90f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 8f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 92f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 25f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 46f , root_child0_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 36f , root_child0_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 6f , root_child0_child0_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child1 . LayoutX ) ; <nl> + Assert . AreEqual ( 58f , root_child1 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child1 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 142f , root_child1 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_margin_should_calculate_based_only_on_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 100 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetMargin ( YogaEdge . Left , 10 . Percent ( ) ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Top , 10 . Percent ( ) ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Right , 10 . Percent ( ) ) ; <nl> + root_child0 . SetMargin ( YogaEdge . Bottom , 10 . Percent ( ) ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . Width = 10 ; <nl> + root_child0_child0 . Height = 10 ; <nl> + root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 20f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 20f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 160f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 20f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 20f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 160f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 150f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_padding_should_calculate_based_only_on_width ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 100 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . SetPadding ( YogaEdge . Left , 10 . Percent ( ) ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Top , 10 . Percent ( ) ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Right , 10 . Percent ( ) ) ; <nl> + root_child0 . SetPadding ( YogaEdge . Bottom , 10 . Percent ( ) ) ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + <nl> + YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . Width = 10 ; <nl> + root_child0_child0 . Height = 10 ; <nl> + root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 20f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 20f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root_child0 . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 170f , root_child0_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 20f , root_child0_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + [ Test ] <nl> + public void Test_percentage_absolute_position ( ) <nl> + { <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> + <nl> + YogaNode root = new YogaNode ( ) ; <nl> + root . Width = 200 ; <nl> + root . Height = 100 ; <nl> + <nl> + YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . PositionType = YogaPositionType . Absolute ; <nl> + root_child0 . SetPosition ( YogaEdge . Left , 30 . Percent ( ) ) ; <nl> + root_child0 . SetPosition ( YogaEdge . Top , 10 . Percent ( ) ) ; <nl> + root_child0 . Width = 10 ; <nl> + root_child0 . Height = 10 ; <nl> + root . Insert ( 0 , root_child0 ) ; <nl> + root . StyleDirection = YogaDirection . LTR ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutHeight ) ; <nl> + <nl> + root . StyleDirection = YogaDirection . RTL ; <nl> + root . CalculateLayout ( ) ; <nl> + <nl> + Assert . AreEqual ( 0f , root . LayoutX ) ; <nl> + Assert . AreEqual ( 0f , root . LayoutY ) ; <nl> + Assert . AreEqual ( 200f , root . LayoutWidth ) ; <nl> + Assert . AreEqual ( 100f , root . LayoutHeight ) ; <nl> + <nl> + Assert . AreEqual ( 60f , root_child0 . LayoutX ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutY ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutWidth ) ; <nl> + Assert . AreEqual ( 10f , root_child0 . LayoutHeight ) ; <nl> + <nl> + YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , false ) ; <nl> + } <nl> + <nl> + } <nl> + } <nl> mmm a / csharp / tests / Facebook . Yoga / YGRoundingTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YGRoundingTest . cs <nl> public void Test_rounding_flex_basis_flex_grow_row_width_of_100 ( ) <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 100f ; <nl> - root . Height = 100f ; <nl> + root . Width = 100 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_flex_basis_flex_grow_row_prime_number_width ( ) <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 113f ; <nl> - root . Height = 100f ; <nl> + root . Width = 113 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> <nl> YogaNode root_child3 = new YogaNode ( ) ; <nl> - root_child3 . FlexGrow = 1f ; <nl> + root_child3 . FlexGrow = 1 ; <nl> root . Insert ( 3 , root_child3 ) ; <nl> <nl> YogaNode root_child4 = new YogaNode ( ) ; <nl> - root_child4 . FlexGrow = 1f ; <nl> + root_child4 . FlexGrow = 1 ; <nl> root . Insert ( 4 , root_child4 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_flex_basis_flex_shrink_row ( ) <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> root . FlexDirection = YogaFlexDirection . Row ; <nl> - root . Width = 101f ; <nl> - root . Height = 100f ; <nl> + root . Width = 101 ; <nl> + root . Height = 100 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexShrink = 1f ; <nl> - root_child0 . FlexBasis = 100f ; <nl> + root_child0 . FlexShrink = 1 ; <nl> + root_child0 . FlexBasis = 100 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexBasis = 25f ; <nl> + root_child1 . FlexBasis = 25 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexBasis = 25f ; <nl> + root_child2 . FlexBasis = 25 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_flex_basis_overrides_main_size ( ) <nl> YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> - root . Height = 113f ; <nl> + root . Width = 100 ; <nl> + root . Height = 113 ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_total_fractial ( ) <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> root_child1 . FlexGrow = 1 . 6f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> public void Test_rounding_total_fractial_nested ( ) <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> - root_child0_child0 . FlexGrow = 1f ; <nl> + root_child0_child0 . FlexGrow = 1 ; <nl> root_child0_child0 . FlexBasis = 0 . 3f ; <nl> root_child0_child0 . SetPosition ( YogaEdge . Bottom , 13 . 3f ) ; <nl> root_child0_child0 . Height = 9 . 9f ; <nl> root_child0 . Insert ( 0 , root_child0_child0 ) ; <nl> <nl> YogaNode root_child0_child1 = new YogaNode ( ) ; <nl> - root_child0_child1 . FlexGrow = 4f ; <nl> + root_child0_child1 . FlexGrow = 4 ; <nl> root_child0_child1 . FlexBasis = 0 . 3f ; <nl> root_child0_child1 . SetPosition ( YogaEdge . Top , 13 . 3f ) ; <nl> root_child0_child1 . Height = 1 . 1f ; <nl> public void Test_rounding_total_fractial_nested ( ) <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> root_child1 . FlexGrow = 1 . 6f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> public void Test_rounding_fractial_input_1 ( ) <nl> YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> root . Height = 113 . 4f ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_fractial_input_2 ( ) <nl> YogaNode . SetExperimentalFeatureEnabled ( YogaExperimentalFeature . Rounding , true ) ; <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> root . Height = 113 . 6f ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_fractial_input_3 ( ) <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> root . SetPosition ( YogaEdge . Top , 0 . 3f ) ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> root . Height = 113 . 4f ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> public void Test_rounding_fractial_input_4 ( ) <nl> <nl> YogaNode root = new YogaNode ( ) ; <nl> root . SetPosition ( YogaEdge . Top , 0 . 7f ) ; <nl> - root . Width = 100f ; <nl> + root . Width = 100 ; <nl> root . Height = 113 . 4f ; <nl> <nl> YogaNode root_child0 = new YogaNode ( ) ; <nl> - root_child0 . FlexGrow = 1f ; <nl> - root_child0 . FlexBasis = 50f ; <nl> - root_child0 . Height = 20f ; <nl> + root_child0 . FlexGrow = 1 ; <nl> + root_child0 . FlexBasis = 50 ; <nl> + root_child0 . Height = 20 ; <nl> root . Insert ( 0 , root_child0 ) ; <nl> <nl> YogaNode root_child1 = new YogaNode ( ) ; <nl> - root_child1 . FlexGrow = 1f ; <nl> - root_child1 . Height = 10f ; <nl> + root_child1 . FlexGrow = 1 ; <nl> + root_child1 . Height = 10 ; <nl> root . Insert ( 1 , root_child1 ) ; <nl> <nl> YogaNode root_child2 = new YogaNode ( ) ; <nl> - root_child2 . FlexGrow = 1f ; <nl> - root_child2 . Height = 10f ; <nl> + root_child2 . FlexGrow = 1 ; <nl> + root_child2 . Height = 10 ; <nl> root . Insert ( 2 , root_child2 ) ; <nl> root . StyleDirection = YogaDirection . LTR ; <nl> root . CalculateLayout ( ) ; <nl> mmm a / csharp / tests / Facebook . Yoga / YogaNodeCreateTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YogaNodeCreateTest . cs <nl> public void TestMultiple ( ) <nl> Assert . AreEqual ( YogaFlexDirection . Column , node . FlexDirection ) ; <nl> Assert . AreEqual ( YogaPositionType . Absolute , node . PositionType ) ; <nl> Assert . AreEqual ( YogaWrap . Wrap , node . Wrap ) ; <nl> - Assert . AreEqual ( 6 , node . GetPosition ( YogaEdge . Top ) ) ; <nl> + Assert . AreEqual ( 6 . Px ( ) , node . GetPosition ( YogaEdge . Top ) ) ; <nl> Assert . IsTrue ( YogaConstants . IsUndefined ( node . GetPosition ( YogaEdge . Bottom ) ) ) ; <nl> - Assert . AreEqual ( 4 , node . GetPosition ( YogaEdge . Right ) ) ; <nl> + Assert . AreEqual ( 4 . Px ( ) , node . GetPosition ( YogaEdge . Right ) ) ; <nl> Assert . IsTrue ( YogaConstants . IsUndefined ( node . GetPosition ( YogaEdge . Left ) ) ) ; <nl> - Assert . AreEqual ( 0 , node . GetMargin ( YogaEdge . Top ) ) ; <nl> - Assert . AreEqual ( 5 , node . GetMargin ( YogaEdge . Bottom ) ) ; <nl> - Assert . AreEqual ( 3 , node . GetMargin ( YogaEdge . Left ) ) ; <nl> - Assert . AreEqual ( 0 , node . GetMargin ( YogaEdge . Right ) ) ; <nl> + Assert . AreEqual ( 0 . Px ( ) , node . GetMargin ( YogaEdge . Top ) ) ; <nl> + Assert . AreEqual ( 5 . Px ( ) , node . GetMargin ( YogaEdge . Bottom ) ) ; <nl> + Assert . AreEqual ( 3 . Px ( ) , node . GetMargin ( YogaEdge . Left ) ) ; <nl> + Assert . AreEqual ( 0 . Px ( ) , node . GetMargin ( YogaEdge . Right ) ) ; <nl> } <nl> <nl> [ Test ] <nl> public void TestFull ( ) <nl> position : new Spacing ( top : 5 , bottom : 6 , left : 7 , right : 8 ) , <nl> margin : new Spacing ( top : 9 , bottom : 10 , left : 11 , right : 12 ) , <nl> padding : new Spacing ( top : 13 , bottom : 14 , left : 15 , right : 16 ) , <nl> - border : new Spacing ( top : 17 , bottom : 18 , left : 19 , right : 20 ) , <nl> + border : new Border ( top : 17 , bottom : 18 , left : 19 , right : 20 ) , <nl> <nl> width : 21 , <nl> height : 22 , <nl> public void TestFull ( ) <nl> <nl> Assert . AreEqual ( 2 , node . FlexGrow ) ; <nl> Assert . AreEqual ( 3 , node . FlexShrink ) ; <nl> - Assert . AreEqual ( 4 , node . FlexBasis ) ; <nl> + Assert . AreEqual ( 4 . Px ( ) , node . FlexBasis ) ; <nl> node . FlexGrow = YogaConstants . Undefined ; <nl> Assert . AreEqual ( 1 , node . FlexGrow ) ; <nl> <nl> - Assert . AreEqual ( 5 , node . GetPosition ( YogaEdge . Top ) ) ; <nl> - Assert . AreEqual ( 6 , node . GetPosition ( YogaEdge . Bottom ) ) ; <nl> - Assert . AreEqual ( 7 , node . GetPosition ( YogaEdge . Left ) ) ; <nl> - Assert . AreEqual ( 8 , node . GetPosition ( YogaEdge . Right ) ) ; <nl> + Assert . AreEqual ( 5 . Px ( ) , node . GetPosition ( YogaEdge . Top ) ) ; <nl> + Assert . AreEqual ( 6 . Px ( ) , node . GetPosition ( YogaEdge . Bottom ) ) ; <nl> + Assert . AreEqual ( 7 . Px ( ) , node . GetPosition ( YogaEdge . Left ) ) ; <nl> + Assert . AreEqual ( 8 . Px ( ) , node . GetPosition ( YogaEdge . Right ) ) ; <nl> <nl> - Assert . AreEqual ( 9 , node . GetMargin ( YogaEdge . Top ) ) ; <nl> - Assert . AreEqual ( 10 , node . GetMargin ( YogaEdge . Bottom ) ) ; <nl> - Assert . AreEqual ( 11 , node . GetMargin ( YogaEdge . Left ) ) ; <nl> - Assert . AreEqual ( 12 , node . GetMargin ( YogaEdge . Right ) ) ; <nl> + Assert . AreEqual ( 9 . Px ( ) , node . GetMargin ( YogaEdge . Top ) ) ; <nl> + Assert . AreEqual ( 10 . Px ( ) , node . GetMargin ( YogaEdge . Bottom ) ) ; <nl> + Assert . AreEqual ( 11 . Px ( ) , node . GetMargin ( YogaEdge . Left ) ) ; <nl> + Assert . AreEqual ( 12 . Px ( ) , node . GetMargin ( YogaEdge . Right ) ) ; <nl> <nl> - Assert . AreEqual ( 13 , node . GetPadding ( YogaEdge . Top ) ) ; <nl> - Assert . AreEqual ( 14 , node . GetPadding ( YogaEdge . Bottom ) ) ; <nl> - Assert . AreEqual ( 15 , node . GetPadding ( YogaEdge . Left ) ) ; <nl> - Assert . AreEqual ( 16 , node . GetPadding ( YogaEdge . Right ) ) ; <nl> + Assert . AreEqual ( 13 . Px ( ) , node . GetPadding ( YogaEdge . Top ) ) ; <nl> + Assert . AreEqual ( 14 . Px ( ) , node . GetPadding ( YogaEdge . Bottom ) ) ; <nl> + Assert . AreEqual ( 15 . Px ( ) , node . GetPadding ( YogaEdge . Left ) ) ; <nl> + Assert . AreEqual ( 16 . Px ( ) , node . GetPadding ( YogaEdge . Right ) ) ; <nl> <nl> Assert . AreEqual ( 17 , node . GetBorder ( YogaEdge . Top ) ) ; <nl> Assert . AreEqual ( 18 , node . GetBorder ( YogaEdge . Bottom ) ) ; <nl> Assert . AreEqual ( 19 , node . GetBorder ( YogaEdge . Left ) ) ; <nl> Assert . AreEqual ( 20 , node . GetBorder ( YogaEdge . Right ) ) ; <nl> <nl> - Assert . AreEqual ( 21 , node . Width ) ; <nl> - Assert . AreEqual ( 22 , node . Height ) ; <nl> - Assert . AreEqual ( 23 , node . MinWidth ) ; <nl> - Assert . AreEqual ( 24 , node . MinHeight ) ; <nl> - Assert . AreEqual ( 25 , node . MaxWidth ) ; <nl> - Assert . AreEqual ( 26 , node . MaxHeight ) ; <nl> + Assert . AreEqual ( 21 . Px ( ) , node . Width ) ; <nl> + Assert . AreEqual ( 22 . Px ( ) , node . Height ) ; <nl> + Assert . AreEqual ( 23 . Px ( ) , node . MinWidth ) ; <nl> + Assert . AreEqual ( 24 . Px ( ) , node . MinHeight ) ; <nl> + Assert . AreEqual ( 25 . Px ( ) , node . MaxWidth ) ; <nl> + Assert . AreEqual ( 26 . Px ( ) , node . MaxHeight ) ; <nl> } <nl> } <nl> } <nl> mmm a / csharp / tests / Facebook . Yoga / YogaNodeTest . cs <nl> ppp b / csharp / tests / Facebook . Yoga / YogaNodeTest . cs <nl> public void TestPrint ( ) <nl> parent . Insert ( 0 , child0 ) ; <nl> parent . Insert ( 0 , child1 ) ; <nl> parent . CalculateLayout ( ) ; <nl> - Assert . AreEqual ( parent . Print ( ) , " { layout : { width : 100 , height : 120 , top : 0 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 100 , height : 120 , children : [ \ n { layout : { width : 35 , height : 45 , top : 0 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 35 , height : 45 , } , \ n { layout : { width : 30 , height : 40 , top : 45 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 30 , height : 40 , } , \ n ] } , \ n " ) ; <nl> + Assert . AreEqual ( " { layout : { width : 100 , height : 120 , top : 0 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 100px , height : 120px , children : [ \ n { layout : { width : 35 , height : 45 , top : 0 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 35px , height : 45px , } , \ n { layout : { width : 30 , height : 40 , top : 45 , left : 0 } , flexDirection : ' column ' , alignItems : ' stretch ' , flexGrow : 0 , flexShrink : 0 , overflow : ' visible ' , width : 30px , height : 40px , } , \ n ] } , \ n " , parent . Print ( ) ) ; <nl> } <nl> <nl> [ Test ] <nl> public void TestCopyStyle ( ) <nl> node1 . MaxHeight = 100 ; <nl> <nl> node0 . CopyStyle ( node1 ) ; <nl> - Assert . AreEqual ( 100 , node0 . MaxHeight ) ; <nl> + Assert . AreEqual ( 100 . Px ( ) , node0 . MaxHeight ) ; <nl> } <nl> <nl> private void ForceGC ( ) <nl> mmm a / enums . py <nl> ppp b / enums . py <nl> <nl> ' LTR ' , <nl> ' RTL ' , <nl> ] , <nl> + ' Unit ' : [ <nl> + ' Undefined ' , <nl> + ' Pixel ' , <nl> + ' Percent ' , <nl> + ] , <nl> ' FlexDirection ' : [ <nl> ' Column ' , <nl> ' ColumnReverse ' , <nl> new file mode 100644 <nl> index 000000000 . . 87c4753c2 <nl> mmm / dev / null <nl> ppp b / gentest / fixtures / YGPercentageTest . html <nl> <nl> + < div id = " percentage_width_height " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : row ; " > <nl> + < div style = " width : 30 % ; height : 30 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_position_left_top " experiments = " Rounding " style = " width : 400px ; height : 400px ; flex - direction : row ; " > <nl> + < div style = " width : 45 % ; height : 55 % ; left : 10 % ; top : 20 % " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_position_bottom_right " experiments = " Rounding " style = " width : 500px ; height : 500px ; flex - direction : row ; " > <nl> + < div style = " width : 55 % ; height : 15 % ; bottom : 10 % ; right : 20 % " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : row ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 50 % ; " > < / div > <nl> + < div style = " flex - grow : 1 ; flex - basis : 25 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_cross " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 50 % ; " > < / div > <nl> + < div style = " flex - grow : 1 ; flex - basis : 25 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_cross_min_height " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; min - height : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 2 ; min - height : 10 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_main_max_height " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : row ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 10 % ; max - height : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 10 % ; max - height : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_cross_max_height " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 10 % ; max - height : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 10 % ; max - height : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_main_max_width " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : row ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 15 % ; max - width : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 10 % ; max - width : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_cross_max_width " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 10 % ; max - width : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 15 % ; max - width : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + <nl> + < div id = " percentage_flex_basis_main_min_width " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : row ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 15 % ; min - width : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 10 % ; min - width : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_flex_basis_cross_min_width " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 10 % ; min - width : 60 % ; " > < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 15 % ; min - width : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_multiple_nested_with_padding_margin_and_percentage_values " experiments = " Rounding " style = " width : 200px ; height : 200px ; flex - direction : column ; " > <nl> + < div style = " flex - grow : 1 ; flex - basis : 10 % ; min - width : 60 % ; margin : 5px ; padding : 3px ; " > <nl> + < div style = " width : 50 % ; margin : 5px ; padding : 3 % ; " > <nl> + < div style = " width : 45 % ; margin : 5 % ; padding : 3px ; " > < / div > <nl> + < / div > <nl> + < / div > <nl> + < div style = " flex - grow : 4 ; flex - basis : 15 % ; min - width : 20 % ; " > < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_margin_should_calculate_based_only_on_width " experiments = " Rounding " style = " width : 200px ; height : 100px ; " > <nl> + < div style = " flex - grow : 1 ; margin : 10 % ; " > <nl> + < div style = " width : 10px ; height : 10px ; " > < / div > <nl> + < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_padding_should_calculate_based_only_on_width " experiments = " Rounding " style = " width : 200px ; height : 100px ; " > <nl> + < div style = " flex - grow : 1 ; padding : 10 % ; " > <nl> + < div style = " width : 10px ; height : 10px ; " > < / div > <nl> + < / div > <nl> + < / div > <nl> + <nl> + < div id = " percentage_absolute_position " experiments = " Rounding " style = " width : 200px ; height : 100px ; " > <nl> + < div style = " position : absolute ; top : 10 % ; left : 30 % ; width : 10px ; height : 10px ; " > < / div > <nl> + < / div > <nl> \ No newline at end of file <nl> mmm a / gentest / gentest - cpp . js <nl> ppp b / gentest / gentest - cpp . js <nl> <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * / <nl> <nl> - function toFloatString ( n ) { <nl> + function toValueCpp ( value ) { <nl> + var n = value . toString ( ) . replace ( ' px ' , ' ' ) . replace ( ' % ' , ' ' ) ; <nl> return n + ( Number ( n ) = = n & & n % 1 ! = = 0 ? ' f ' : ' ' ) ; <nl> } <nl> <nl> + function toFunctionName ( value ) { <nl> + if ( value . indexOf ( ' % ' ) > = 0 ) { <nl> + return ' Percent ' ; <nl> + } <nl> + return ' ' ; <nl> + } <nl> + <nl> var CPPEmitter = function ( ) { <nl> Emitter . call ( this , ' cpp ' , ' ' ) ; <nl> } ; <nl> CPPEmitter . prototype = Object . create ( Emitter . prototype , { <nl> } } , <nl> <nl> AssertEQ : { value : function ( v0 , v1 ) { <nl> - this . push ( ' ASSERT_FLOAT_EQ ( ' + toFloatString ( v0 ) + ' , ' + v1 + ' ) ; ' ) ; <nl> + this . push ( ' ASSERT_FLOAT_EQ ( ' + toValueCpp ( v0 ) + ' , ' + v1 + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGAlignAuto : { value : ' YGAlignAuto ' } , <nl> CPPEmitter . prototype = Object . create ( Emitter . prototype , { <nl> } } , <nl> <nl> YGNodeStyleSetAlignContent : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetAlignContent ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetAlignContent ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignItems : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetAlignItems ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetAlignItems ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignSelf : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetAlignSelf ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetAlignSelf ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetBorder : { value : function ( nodeName , edge , value ) { <nl> - this . push ( ' YGNodeStyleSetBorder ( ' + nodeName + ' , ' + edge + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetBorder ( ' + nodeName + ' , ' + edge + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetDirection : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetDirection ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetDirection ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexBasis : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetFlexBasis ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetFlexBasis ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexDirection : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetFlexDirection ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetFlexDirection ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexGrow : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetFlexGrow ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetFlexGrow ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexShrink : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetFlexShrink ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetFlexShrink ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexWrap : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetFlexWrap ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetFlexWrap ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetHeight : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetHeight ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetHeight ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetJustifyContent : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetJustifyContent ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetJustifyContent ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMargin : { value : function ( nodeName , edge , value ) { <nl> - this . push ( ' YGNodeStyleSetMargin ( ' + nodeName + ' , ' + edge + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetMargin ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + edge + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxHeight : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetMaxHeight ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetMaxHeight ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxWidth : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetMaxWidth ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetMaxWidth ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinHeight : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetMinHeight ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetMinHeight ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinWidth : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetMinWidth ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetMinWidth ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetOverflow : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetOverflow ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetOverflow ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPadding : { value : function ( nodeName , edge , value ) { <nl> - this . push ( ' YGNodeStyleSetPadding ( ' + nodeName + ' , ' + edge + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetPadding ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + edge + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPosition : { value : function ( nodeName , edge , value ) { <nl> - this . push ( ' YGNodeStyleSetPosition ( ' + nodeName + ' , ' + edge + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetPosition ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + edge + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPositionType : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetPositionType ( ' + nodeName + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetPositionType ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetWidth : { value : function ( nodeName , value ) { <nl> - this . push ( ' YGNodeStyleSetWidth ( ' + nodeName + ' , ' + toFloatString ( value ) + ' ) ; ' ) ; <nl> + this . push ( ' YGNodeStyleSetWidth ' + toFunctionName ( value ) + ' ( ' + nodeName + ' , ' + toValueCpp ( value ) + ' ) ; ' ) ; <nl> } } , <nl> } ) ; <nl> mmm a / gentest / gentest - cs . js <nl> ppp b / gentest / gentest - cs . js <nl> <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * / <nl> <nl> + function toValueCs ( value ) { <nl> + var n = value . toString ( ) . replace ( ' px ' , ' ' ) . replace ( ' % ' , ' ' ) ; <nl> + return n + ( Number ( n ) = = n & & n % 1 ! = = 0 ? ' f ' : ' ' ) ; <nl> + } <nl> + <nl> + function toCsUnitValue ( value ) { <nl> + var methodName = ' ' ; <nl> + if ( value . indexOf ( ' % ' ) > = 0 ) { <nl> + methodName = ' . Percent ( ) ' ; <nl> + } <nl> + return toValueCs ( value ) + methodName ; <nl> + } <nl> + <nl> var CSEmitter = function ( ) { <nl> Emitter . call ( this , ' cs ' , ' ' ) ; <nl> } ; <nl> CSEmitter . prototype = Object . create ( Emitter . prototype , { <nl> } } , <nl> <nl> YGNodeStyleSetAlignContent : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . AlignContent = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . AlignContent = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignItems : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . AlignItems = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . AlignItems = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignSelf : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . AlignSelf = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . AlignSelf = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetBorder : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . SetBorder ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . SetBorder ( ' + edge + ' , ' + toValueCs ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetDirection : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . StyleDirection = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . StyleDirection = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexBasis : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . FlexBasis = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . FlexBasis = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexDirection : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . FlexDirection = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . FlexDirection = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexGrow : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . FlexGrow = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . FlexGrow = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexShrink : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . FlexShrink = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . FlexShrink = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexWrap : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . Wrap = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . Wrap = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . Height = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . Height = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetJustifyContent : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . JustifyContent = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . JustifyContent = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMargin : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . SetMargin ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . SetMargin ( ' + edge + ' , ' + toCsUnitValue ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . MaxHeight = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . MaxHeight = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . MaxWidth = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . MaxWidth = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . MinHeight = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . MinHeight = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . MinWidth = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . MinWidth = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetOverflow : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . Overflow = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . Overflow = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPadding : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . SetPadding ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . SetPadding ( ' + edge + ' , ' + toCsUnitValue ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPosition : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . SetPosition ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . SetPosition ( ' + edge + ' , ' + toCsUnitValue ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPositionType : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . PositionType = ' + value + ' ; ' ) ; <nl> + this . push ( nodeName + ' . PositionType = ' + toValueCs ( value ) + ' ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . Width = ' + value + ' f ; ' ) ; <nl> + this . push ( nodeName + ' . Width = ' + toCsUnitValue ( value ) + ' ; ' ) ; <nl> } } , <nl> } ) ; <nl> mmm a / gentest / gentest - java . js <nl> ppp b / gentest / gentest - java . js <nl> <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * / <nl> <nl> + function toValueJava ( value ) { <nl> + var n = value . toString ( ) . replace ( ' px ' , ' ' ) . replace ( ' % ' , ' ' ) ; <nl> + return n + ( Number ( n ) = = n & & n % 1 ! = = 0 ? ' ' : ' ' ) ; <nl> + } <nl> + <nl> + function toMethodName ( value ) { <nl> + if ( value . indexOf ( ' % ' ) > = 0 ) { <nl> + return ' Percent ' ; <nl> + } <nl> + return ' ' ; <nl> + } <nl> + <nl> var JavaEmitter = function ( ) { <nl> Emitter . call ( this , ' java ' , ' ' ) ; <nl> } ; <nl> JavaEmitter . prototype = Object . create ( Emitter . prototype , { <nl> } } , <nl> <nl> YGNodeStyleSetAlignContent : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setAlignContent ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setAlignContent ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignItems : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setAlignItems ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setAlignItems ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetAlignSelf : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setAlignSelf ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setAlignSelf ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetBorder : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . setBorder ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setBorder ( ' + edge + ' , ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetDirection : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setDirection ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setDirection ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexBasis : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setFlexBasis ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setFlexBasis ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexDirection : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setFlexDirection ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setFlexDirection ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexGrow : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setFlexGrow ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setFlexGrow ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexShrink : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setFlexShrink ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setFlexShrink ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetFlexWrap : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setWrap ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setWrap ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setHeight ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setHeight ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetJustifyContent : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setJustifyContent ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setJustifyContent ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMargin : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . setMargin ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setMargin ' + toMethodName ( value ) + ' ( ' + edge + ' , ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setMaxHeight ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setMaxHeight ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMaxWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setMaxWidth ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setMaxWidth ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinHeight : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setMinHeight ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setMinHeight ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetMinWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setMinWidth ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setMinWidth ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetOverflow : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setOverflow ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setOverflow ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPadding : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . setPadding ( ' + edge + ' , ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setPadding ' + toMethodName ( value ) + ' ( ' + edge + ' , ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPosition : { value : function ( nodeName , edge , value ) { <nl> - this . push ( nodeName + ' . setPosition ( ' + edge + ' , ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setPosition ' + toMethodName ( value ) + ' ( ' + edge + ' , ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetPositionType : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setPositionType ( ' + value + ' ) ; ' ) ; <nl> + this . push ( nodeName + ' . setPositionType ( ' + toValueJava ( value ) + ' ) ; ' ) ; <nl> } } , <nl> <nl> YGNodeStyleSetWidth : { value : function ( nodeName , value ) { <nl> - this . push ( nodeName + ' . setWidth ( ' + value + ' f ) ; ' ) ; <nl> + this . push ( nodeName + ' . setWidth ' + toMethodName ( value ) + ' ( ' + toValueJava ( value ) + ' f ) ; ' ) ; <nl> } } , <nl> } ) ; <nl> mmm a / gentest / gentest . js <nl> ppp b / gentest / gentest . js <nl> function pixelValue ( e , value ) { <nl> switch ( value ) { <nl> case ' auto ' : return e . YGUndefined ; <nl> case ' undefined ' : return e . YGUndefined ; <nl> - default : return value . replace ( ' px ' , ' ' ) ; <nl> + default : return value ; <nl> } <nl> } <nl> <nl> mmm a / java / com / facebook / yoga / YogaConstants . java <nl> ppp b / java / com / facebook / yoga / YogaConstants . java <nl> <nl> public static boolean isUndefined ( float value ) { <nl> return Float . compare ( value , UNDEFINED ) = = 0 ; <nl> } <nl> + <nl> + public static boolean isUndefined ( YogaValue value ) { <nl> + return value . unit = = YogaUnit . UNDEFINED ; <nl> + } <nl> } <nl> mmm a / java / com / facebook / yoga / YogaNode . java <nl> ppp b / java / com / facebook / yoga / YogaNode . java <nl> public void setFlexShrink ( float flexShrink ) { <nl> jni_YGNodeStyleSetFlexShrink ( mNativePointer , flexShrink ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetFlexBasis ( long nativePointer ) ; <nl> + private native Object jni_YGNodeStyleGetFlexBasis ( long nativePointer ) ; <nl> @ Override <nl> - public float getFlexBasis ( ) { <nl> - return jni_YGNodeStyleGetFlexBasis ( mNativePointer ) ; <nl> + public YogaValue getFlexBasis ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetFlexBasis ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetFlexBasis ( long nativePointer , float flexBasis ) ; <nl> public void setFlexBasis ( float flexBasis ) { <nl> jni_YGNodeStyleSetFlexBasis ( mNativePointer , flexBasis ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetMargin ( long nativePointer , int edge ) ; <nl> + private native void jni_YGNodeStyleSetFlexBasisPercent ( long nativePointer , float percent ) ; <nl> @ Override <nl> - public float getMargin ( YogaEdge edge ) { <nl> + public void setFlexBasisPercent ( float percent ) { <nl> + jni_YGNodeStyleSetFlexBasisPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetMargin ( long nativePointer , int edge ) ; <nl> + @ Override <nl> + public YogaValue getMargin ( YogaEdge edge ) { <nl> if ( ! mHasSetMargin ) { <nl> - return edge . intValue ( ) < YogaEdge . START . intValue ( ) ? 0 : YogaConstants . UNDEFINED ; <nl> + return edge . intValue ( ) < YogaEdge . START . intValue ( ) ? YogaValue . ZERO : YogaValue . UNDEFINED ; <nl> } <nl> - return jni_YGNodeStyleGetMargin ( mNativePointer , edge . intValue ( ) ) ; <nl> + return ( YogaValue ) jni_YGNodeStyleGetMargin ( mNativePointer , edge . intValue ( ) ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetMargin ( long nativePointer , int edge , float margin ) ; <nl> public void setMargin ( YogaEdge edge , float margin ) { <nl> jni_YGNodeStyleSetMargin ( mNativePointer , edge . intValue ( ) , margin ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetPadding ( long nativePointer , int edge ) ; <nl> + private native void jni_YGNodeStyleSetMarginPercent ( long nativePointer , int edge , float percent ) ; <nl> @ Override <nl> - public float getPadding ( YogaEdge edge ) { <nl> + public void setMarginPercent ( YogaEdge edge , float percent ) { <nl> + mHasSetMargin = true ; <nl> + jni_YGNodeStyleSetMarginPercent ( mNativePointer , edge . intValue ( ) , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetPadding ( long nativePointer , int edge ) ; <nl> + @ Override <nl> + public YogaValue getPadding ( YogaEdge edge ) { <nl> if ( ! mHasSetPadding ) { <nl> - return edge . intValue ( ) < YogaEdge . START . intValue ( ) ? 0 : YogaConstants . UNDEFINED ; <nl> + return edge . intValue ( ) < YogaEdge . START . intValue ( ) ? YogaValue . ZERO : YogaValue . UNDEFINED ; <nl> } <nl> - return jni_YGNodeStyleGetPadding ( mNativePointer , edge . intValue ( ) ) ; <nl> + return ( YogaValue ) jni_YGNodeStyleGetPadding ( mNativePointer , edge . intValue ( ) ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetPadding ( long nativePointer , int edge , float padding ) ; <nl> public void setPadding ( YogaEdge edge , float padding ) { <nl> jni_YGNodeStyleSetPadding ( mNativePointer , edge . intValue ( ) , padding ) ; <nl> } <nl> <nl> + private native void jni_YGNodeStyleSetPaddingPercent ( long nativePointer , int edge , float percent ) ; <nl> + @ Override <nl> + public void setPaddingPercent ( YogaEdge edge , float percent ) { <nl> + mHasSetPadding = true ; <nl> + jni_YGNodeStyleSetPaddingPercent ( mNativePointer , edge . intValue ( ) , percent ) ; <nl> + } <nl> + <nl> private native float jni_YGNodeStyleGetBorder ( long nativePointer , int edge ) ; <nl> @ Override <nl> public float getBorder ( YogaEdge edge ) { <nl> public void setBorder ( YogaEdge edge , float border ) { <nl> jni_YGNodeStyleSetBorder ( mNativePointer , edge . intValue ( ) , border ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetPosition ( long nativePointer , int edge ) ; <nl> + private native Object jni_YGNodeStyleGetPosition ( long nativePointer , int edge ) ; <nl> @ Override <nl> - public float getPosition ( YogaEdge edge ) { <nl> + public YogaValue getPosition ( YogaEdge edge ) { <nl> if ( ! mHasSetPosition ) { <nl> - return YogaConstants . UNDEFINED ; <nl> + return YogaValue . UNDEFINED ; <nl> } <nl> - return jni_YGNodeStyleGetPosition ( mNativePointer , edge . intValue ( ) ) ; <nl> + return ( YogaValue ) jni_YGNodeStyleGetPosition ( mNativePointer , edge . intValue ( ) ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetPosition ( long nativePointer , int edge , float position ) ; <nl> public void setPosition ( YogaEdge edge , float position ) { <nl> jni_YGNodeStyleSetPosition ( mNativePointer , edge . intValue ( ) , position ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetWidth ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetPositionPercent ( long nativePointer , int edge , float percent ) ; <nl> @ Override <nl> - public float getWidth ( ) { <nl> - return jni_YGNodeStyleGetWidth ( mNativePointer ) ; <nl> + public void setPositionPercent ( YogaEdge edge , float percent ) { <nl> + mHasSetPosition = true ; <nl> + jni_YGNodeStyleSetPositionPercent ( mNativePointer , edge . intValue ( ) , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetWidth ( long nativePointer ) ; <nl> + @ Override <nl> + public YogaValue getWidth ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetWidth ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetWidth ( long nativePointer , float width ) ; <nl> public void setWidth ( float width ) { <nl> jni_YGNodeStyleSetWidth ( mNativePointer , width ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetHeight ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetWidthPercent ( long nativePointer , float percent ) ; <nl> @ Override <nl> - public float getHeight ( ) { <nl> - return jni_YGNodeStyleGetHeight ( mNativePointer ) ; <nl> + public void setWidthPercent ( float percent ) { <nl> + jni_YGNodeStyleSetWidthPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetHeight ( long nativePointer ) ; <nl> + @ Override <nl> + public YogaValue getHeight ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetHeight ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetHeight ( long nativePointer , float height ) ; <nl> public void setHeight ( float height ) { <nl> jni_YGNodeStyleSetHeight ( mNativePointer , height ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetMinWidth ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetHeightPercent ( long nativePointer , float percent ) ; <nl> + @ Override <nl> + public void setHeightPercent ( float percent ) { <nl> + jni_YGNodeStyleSetHeightPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetMinWidth ( long nativePointer ) ; <nl> @ Override <nl> - public float getMinWidth ( ) { <nl> - return jni_YGNodeStyleGetMinWidth ( mNativePointer ) ; <nl> + public YogaValue getMinWidth ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetMinWidth ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetMinWidth ( long nativePointer , float minWidth ) ; <nl> public void setMinWidth ( float minWidth ) { <nl> jni_YGNodeStyleSetMinWidth ( mNativePointer , minWidth ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetMinHeight ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetMinWidthPercent ( long nativePointer , float percent ) ; <nl> @ Override <nl> - public float getMinHeight ( ) { <nl> - return jni_YGNodeStyleGetMinHeight ( mNativePointer ) ; <nl> + public void setMinWidthPercent ( float percent ) { <nl> + jni_YGNodeStyleSetMinWidthPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetMinHeight ( long nativePointer ) ; <nl> + @ Override <nl> + public YogaValue getMinHeight ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetMinHeight ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetMinHeight ( long nativePointer , float minHeight ) ; <nl> public void setMinHeight ( float minHeight ) { <nl> jni_YGNodeStyleSetMinHeight ( mNativePointer , minHeight ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetMaxWidth ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetMinHeightPercent ( long nativePointer , float percent ) ; <nl> @ Override <nl> - public float getMaxWidth ( ) { <nl> - return jni_YGNodeStyleGetMaxWidth ( mNativePointer ) ; <nl> + public void setMinHeightPercent ( float percent ) { <nl> + jni_YGNodeStyleSetMinHeightPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetMaxWidth ( long nativePointer ) ; <nl> + @ Override <nl> + public YogaValue getMaxWidth ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetMaxWidth ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetMaxWidth ( long nativePointer , float maxWidth ) ; <nl> public void setMaxWidth ( float maxWidth ) { <nl> jni_YGNodeStyleSetMaxWidth ( mNativePointer , maxWidth ) ; <nl> } <nl> <nl> - private native float jni_YGNodeStyleGetMaxHeight ( long nativePointer ) ; <nl> + private native void jni_YGNodeStyleSetMaxWidthPercent ( long nativePointer , float percent ) ; <nl> + @ Override <nl> + public void setMaxWidthPercent ( float percent ) { <nl> + jni_YGNodeStyleSetMaxWidthPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> + private native Object jni_YGNodeStyleGetMaxHeight ( long nativePointer ) ; <nl> @ Override <nl> - public float getMaxHeight ( ) { <nl> - return jni_YGNodeStyleGetMaxHeight ( mNativePointer ) ; <nl> + public YogaValue getMaxHeight ( ) { <nl> + return ( YogaValue ) jni_YGNodeStyleGetMaxHeight ( mNativePointer ) ; <nl> } <nl> <nl> private native void jni_YGNodeStyleSetMaxHeight ( long nativePointer , float maxheight ) ; <nl> public void setMaxHeight ( float maxheight ) { <nl> jni_YGNodeStyleSetMaxHeight ( mNativePointer , maxheight ) ; <nl> } <nl> <nl> + private native void jni_YGNodeStyleSetMaxHeightPercent ( long nativePointer , float percent ) ; <nl> + @ Override <nl> + public void setMaxHeightPercent ( float percent ) { <nl> + jni_YGNodeStyleSetMaxHeightPercent ( mNativePointer , percent ) ; <nl> + } <nl> + <nl> private native float jni_YGNodeStyleGetAspectRatio ( long nativePointer ) ; <nl> public float getAspectRatio ( ) { <nl> return jni_YGNodeStyleGetAspectRatio ( mNativePointer ) ; <nl> mmm a / java / com / facebook / yoga / YogaNodeAPI . java <nl> ppp b / java / com / facebook / yoga / YogaNodeAPI . java <nl> <nl> void setFlexGrow ( float flexGrow ) ; <nl> float getFlexShrink ( ) ; <nl> void setFlexShrink ( float flexShrink ) ; <nl> - float getFlexBasis ( ) ; <nl> + YogaValue getFlexBasis ( ) ; <nl> void setFlexBasis ( float flexBasis ) ; <nl> - float getMargin ( YogaEdge edge ) ; <nl> + void setFlexBasisPercent ( float percent ) ; <nl> + YogaValue getMargin ( YogaEdge edge ) ; <nl> void setMargin ( YogaEdge edge , float margin ) ; <nl> - float getPadding ( YogaEdge edge ) ; <nl> + void setMarginPercent ( YogaEdge edge , float percent ) ; <nl> + YogaValue getPadding ( YogaEdge edge ) ; <nl> void setPadding ( YogaEdge edge , float padding ) ; <nl> + void setPaddingPercent ( YogaEdge edge , float percent ) ; <nl> float getBorder ( YogaEdge edge ) ; <nl> void setBorder ( YogaEdge edge , float border ) ; <nl> - float getPosition ( YogaEdge edge ) ; <nl> + YogaValue getPosition ( YogaEdge edge ) ; <nl> void setPosition ( YogaEdge edge , float position ) ; <nl> - float getWidth ( ) ; <nl> + void setPositionPercent ( YogaEdge edge , float percent ) ; <nl> + YogaValue getWidth ( ) ; <nl> void setWidth ( float width ) ; <nl> - float getHeight ( ) ; <nl> + void setWidthPercent ( float percent ) ; <nl> + YogaValue getHeight ( ) ; <nl> void setHeight ( float height ) ; <nl> - float getMaxWidth ( ) ; <nl> + void setHeightPercent ( float percent ) ; <nl> + YogaValue getMaxWidth ( ) ; <nl> void setMaxWidth ( float maxWidth ) ; <nl> - float getMinWidth ( ) ; <nl> + void setMaxWidthPercent ( float percent ) ; <nl> + YogaValue getMinWidth ( ) ; <nl> void setMinWidth ( float minWidth ) ; <nl> - float getMaxHeight ( ) ; <nl> + void setMinWidthPercent ( float percent ) ; <nl> + YogaValue getMaxHeight ( ) ; <nl> void setMaxHeight ( float maxHeight ) ; <nl> - float getMinHeight ( ) ; <nl> + void setMaxHeightPercent ( float percent ) ; <nl> + YogaValue getMinHeight ( ) ; <nl> void setMinHeight ( float minHeight ) ; <nl> + void setMinHeightPercent ( float percent ) ; <nl> float getLayoutX ( ) ; <nl> float getLayoutY ( ) ; <nl> float getLayoutWidth ( ) ; <nl> new file mode 100644 <nl> index 000000000 . . 43e4b787b <nl> mmm / dev / null <nl> ppp b / java / com / facebook / yoga / YogaUnit . java <nl> <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> + <nl> + package com . facebook . yoga ; <nl> + <nl> + import com . facebook . proguard . annotations . DoNotStrip ; <nl> + <nl> + @ DoNotStrip <nl> + public enum YogaUnit { <nl> + UNDEFINED ( 0 ) , <nl> + PIXEL ( 1 ) , <nl> + PERCENT ( 2 ) ; <nl> + <nl> + private int mIntValue ; <nl> + <nl> + YogaUnit ( int intValue ) { <nl> + mIntValue = intValue ; <nl> + } <nl> + <nl> + public int intValue ( ) { <nl> + return mIntValue ; <nl> + } <nl> + <nl> + public static YogaUnit fromInt ( int value ) { <nl> + switch ( value ) { <nl> + case 0 : return UNDEFINED ; <nl> + case 1 : return PIXEL ; <nl> + case 2 : return PERCENT ; <nl> + default : throw new IllegalArgumentException ( " Unkown enum value : " + value ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . c2d257fc2 <nl> mmm / dev / null <nl> ppp b / java / com / facebook / yoga / YogaValue . java <nl> <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> + <nl> + package com . facebook . yoga ; <nl> + <nl> + import com . facebook . proguard . annotations . DoNotStrip ; <nl> + <nl> + @ DoNotStrip <nl> + public class YogaValue { <nl> + static final YogaValue UNDEFINED = new YogaValue ( YogaConstants . UNDEFINED , YogaUnit . UNDEFINED ) ; <nl> + static final YogaValue ZERO = new YogaValue ( 0 , YogaUnit . PIXEL ) ; <nl> + <nl> + public final float value ; <nl> + public final YogaUnit unit ; <nl> + <nl> + YogaValue ( float value , YogaUnit unit ) { <nl> + this . value = value ; <nl> + this . unit = unit ; <nl> + } <nl> + <nl> + @ DoNotStrip <nl> + YogaValue ( float value , int unit ) { <nl> + this ( value , YogaUnit . fromInt ( unit ) ) ; <nl> + } <nl> + <nl> + @ Override <nl> + public boolean equals ( Object other ) { <nl> + if ( other instanceof YogaValue ) { <nl> + final YogaValue otherValue = ( YogaValue ) other ; <nl> + return value = = otherValue . value & & unit = = otherValue . unit ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + @ Override <nl> + public int hashCode ( ) { <nl> + return Float . floatToIntBits ( value ) + unit . intValue ( ) ; <nl> + } <nl> + } <nl> mmm a / java / jni / YGJNI . cpp <nl> ppp b / java / jni / YGJNI . cpp <nl> <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * / <nl> <nl> - # include < yoga / Yoga . h > <nl> # include < fb / fbjni . h > <nl> # include < iostream > <nl> + # include < yoga / Yoga . h > <nl> <nl> using namespace facebook : : jni ; <nl> using namespace std ; <nl> static YGSize YGJNIMeasureFunc ( YGNodeRef node , <nl> int32_t wBits = 0xFFFFFFFF & ( measureResult > > 32 ) ; <nl> int32_t hBits = 0xFFFFFFFF & measureResult ; <nl> <nl> - const float * measuredWidth = reinterpret_cast < float * > ( & wBits ) ; <nl> - const float * measuredHeight = reinterpret_cast < float * > ( & hBits ) ; <nl> + const float * measuredWidth = reinterpret_cast < float * > ( & wBits ) ; <nl> + const float * measuredHeight = reinterpret_cast < float * > ( & hBits ) ; <nl> <nl> return YGSize { * measuredWidth , * measuredHeight } ; <nl> } else { <nl> void jni_YGNodeCopyStyle ( alias_ref < jobject > , jlong dstNativePointer , jlong srcNa <nl> YGNodeCopyStyle ( _jlong2YGNodeRef ( dstNativePointer ) , _jlong2YGNodeRef ( srcNativePointer ) ) ; <nl> } <nl> <nl> + struct JYogaValue : public JavaClass < JYogaValue > { <nl> + constexpr static auto kJavaDescriptor = " Lcom / facebook / yoga / YogaValue ; " ; <nl> + <nl> + static local_ref < javaobject > create ( YGValue value ) { <nl> + return newInstance ( value . value , static_cast < int > ( value . unit ) ) ; <nl> + } <nl> + } ; <nl> + <nl> # define YG_NODE_JNI_STYLE_PROP ( javatype , type , name ) \ <nl> javatype jni_YGNodeStyleGet # # name ( alias_ref < jobject > , jlong nativePointer ) { \ <nl> return ( javatype ) YGNodeStyleGet # # name ( _jlong2YGNodeRef ( nativePointer ) ) ; \ <nl> void jni_YGNodeCopyStyle ( alias_ref < jobject > , jlong dstNativePointer , jlong srcNa <nl> YGNodeStyleSet # # name ( _jlong2YGNodeRef ( nativePointer ) , static_cast < type > ( value ) ) ; \ <nl> } <nl> <nl> + # define YG_NODE_JNI_STYLE_UNIT_PROP ( name ) \ <nl> + local_ref < jobject > jni_YGNodeStyleGet # # name ( alias_ref < jobject > , jlong nativePointer ) { \ <nl> + return JYogaValue : : create ( YGNodeStyleGet # # name ( _jlong2YGNodeRef ( nativePointer ) ) ) ; \ <nl> + } \ <nl> + \ <nl> + void jni_YGNodeStyleSet # # name ( alias_ref < jobject > , jlong nativePointer , jfloat value ) { \ <nl> + YGNodeStyleSet # # name ( _jlong2YGNodeRef ( nativePointer ) , static_cast < float > ( value ) ) ; \ <nl> + } \ <nl> + \ <nl> + void jni_YGNodeStyleSet # # name # # Percent ( alias_ref < jobject > , jlong nativePointer , jfloat value ) { \ <nl> + YGNodeStyleSet # # name # # Percent ( _jlong2YGNodeRef ( nativePointer ) , static_cast < float > ( value ) ) ; \ <nl> + } <nl> + <nl> # define YG_NODE_JNI_STYLE_EDGE_PROP ( javatype , type , name ) \ <nl> javatype jni_YGNodeStyleGet # # name ( alias_ref < jobject > , jlong nativePointer , jint edge ) { \ <nl> return ( javatype ) YGNodeStyleGet # # name ( _jlong2YGNodeRef ( nativePointer ) , \ <nl> void jni_YGNodeCopyStyle ( alias_ref < jobject > , jlong dstNativePointer , jlong srcNa <nl> static_cast < type > ( value ) ) ; \ <nl> } <nl> <nl> + # define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP ( name ) \ <nl> + local_ref < jobject > jni_YGNodeStyleGet # # name ( alias_ref < jobject > , \ <nl> + jlong nativePointer , \ <nl> + jint edge ) { \ <nl> + return JYogaValue : : create ( \ <nl> + YGNodeStyleGet # # name ( _jlong2YGNodeRef ( nativePointer ) , static_cast < YGEdge > ( edge ) ) ) ; \ <nl> + } \ <nl> + \ <nl> + void jni_YGNodeStyleSet # # name ( alias_ref < jobject > , jlong nativePointer , jint edge , jfloat value ) { \ <nl> + YGNodeStyleSet # # name ( _jlong2YGNodeRef ( nativePointer ) , \ <nl> + static_cast < YGEdge > ( edge ) , \ <nl> + static_cast < float > ( value ) ) ; \ <nl> + } \ <nl> + \ <nl> + void jni_YGNodeStyleSet # # name # # Percent ( alias_ref < jobject > , \ <nl> + jlong nativePointer , \ <nl> + jint edge , \ <nl> + jfloat value ) { \ <nl> + YGNodeStyleSet # # name # # Percent ( _jlong2YGNodeRef ( nativePointer ) , \ <nl> + static_cast < YGEdge > ( edge ) , \ <nl> + static_cast < float > ( value ) ) ; \ <nl> + } <nl> + <nl> YG_NODE_JNI_STYLE_PROP ( jint , YGDirection , Direction ) ; <nl> YG_NODE_JNI_STYLE_PROP ( jint , YGFlexDirection , FlexDirection ) ; <nl> YG_NODE_JNI_STYLE_PROP ( jint , YGJustify , JustifyContent ) ; <nl> void jni_YGNodeStyleSetFlex ( alias_ref < jobject > , jlong nativePointer , jfloat valu <nl> } <nl> YG_NODE_JNI_STYLE_PROP ( jfloat , float , FlexGrow ) ; <nl> YG_NODE_JNI_STYLE_PROP ( jfloat , float , FlexShrink ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , FlexBasis ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( FlexBasis ) ; <nl> <nl> - YG_NODE_JNI_STYLE_EDGE_PROP ( jfloat , float , Position ) ; <nl> - YG_NODE_JNI_STYLE_EDGE_PROP ( jfloat , float , Margin ) ; <nl> - YG_NODE_JNI_STYLE_EDGE_PROP ( jfloat , float , Padding ) ; <nl> + YG_NODE_JNI_STYLE_EDGE_UNIT_PROP ( Position ) ; <nl> + YG_NODE_JNI_STYLE_EDGE_UNIT_PROP ( Margin ) ; <nl> + YG_NODE_JNI_STYLE_EDGE_UNIT_PROP ( Padding ) ; <nl> YG_NODE_JNI_STYLE_EDGE_PROP ( jfloat , float , Border ) ; <nl> <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , Width ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , MinWidth ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , MaxWidth ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , Height ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , MinHeight ) ; <nl> - YG_NODE_JNI_STYLE_PROP ( jfloat , float , MaxHeight ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( Width ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( MinWidth ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( MaxWidth ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( Height ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( MinHeight ) ; <nl> + YG_NODE_JNI_STYLE_UNIT_PROP ( MaxHeight ) ; <nl> <nl> / / Yoga specific properties , not compatible with flexbox specification <nl> YG_NODE_JNI_STYLE_PROP ( jfloat , float , AspectRatio ) ; <nl> jint JNI_OnLoad ( JavaVM * vm , void * ) { <nl> YGMakeNativeMethod ( jni_YGNodeMarkLayoutSeen ) , <nl> YGMakeNativeMethod ( jni_YGNodeSetHasMeasureFunc ) , <nl> YGMakeNativeMethod ( jni_YGNodeCopyStyle ) , <nl> - <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetDirection ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetDirection ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetFlexDirection ) , <nl> jint JNI_OnLoad ( JavaVM * vm , void * ) { <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetFlexShrink ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetFlexBasis ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetFlexBasis ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetFlexBasisPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetMargin ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetMargin ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetMarginPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetPadding ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetPadding ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetPaddingPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetBorder ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetBorder ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetPosition ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetPosition ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetPositionPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetWidth ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetWidth ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetWidthPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetHeight ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetHeight ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetHeightPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetMinWidth ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetMinWidth ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetMinWidthPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetMinHeight ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetMinHeight ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetMinHeightPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetMaxWidth ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetMaxWidth ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetMaxWidthPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetMaxHeight ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetMaxHeight ) , <nl> + YGMakeNativeMethod ( jni_YGNodeStyleSetMaxHeightPercent ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleGetAspectRatio ) , <nl> YGMakeNativeMethod ( jni_YGNodeStyleSetAspectRatio ) , <nl> - <nl> YGMakeNativeMethod ( jni_YGNodeGetInstanceCount ) , <nl> YGMakeNativeMethod ( jni_YGSetLogger ) , <nl> YGMakeNativeMethod ( jni_YGLog ) , <nl> new file mode 100644 <nl> index 000000000 . . c746008aa <nl> mmm / dev / null <nl> ppp b / java / tests / com / facebook / yoga / YGPercentageTest . java <nl> <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> + <nl> + / / @ Generated by gentest / gentest . rb from gentest / fixtures / YGPercentageTest . html <nl> + <nl> + package com . facebook . yoga ; <nl> + <nl> + import org . junit . Test ; <nl> + <nl> + import static org . junit . Assert . assertEquals ; <nl> + <nl> + public class YGPercentageTest { <nl> + @ Test <nl> + public void test_percentage_width_height ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setWidthPercent ( 30f ) ; <nl> + root_child0 . setHeightPercent ( 30f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 140f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_position_left_top ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 400f ) ; <nl> + root . setHeight ( 400f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . LEFT , 10f ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . TOP , 20f ) ; <nl> + root_child0 . setWidthPercent ( 45f ) ; <nl> + root_child0 . setHeightPercent ( 55f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 400f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 400f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 40f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 80f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 180f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 220f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 400f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 400f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 260f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 80f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 180f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 220f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_position_bottom_right ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 500f ) ; <nl> + root . setHeight ( 500f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . RIGHT , 20f ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . BOTTOM , 10f ) ; <nl> + root_child0 . setWidthPercent ( 55f ) ; <nl> + root_child0 . setHeightPercent ( 15f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 500f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 500f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( - 100f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( - 50f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 275f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 500f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 500f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 125f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( - 50f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 275f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 50f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 1f ) ; <nl> + root_child1 . setFlexBasisPercent ( 25f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 125f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 75f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_cross ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 50f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 1f ) ; <nl> + root_child1 . setFlexBasisPercent ( 25f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 125f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 75f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_cross_min_height ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setMinHeightPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 2f ) ; <nl> + root_child1 . setMinHeightPercent ( 10f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 140f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 140f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 140f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 140f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_main_max_height ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 10f ) ; <nl> + root_child0 . setMaxHeightPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 10f ) ; <nl> + root_child1 . setMaxHeightPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 52f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 52f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 148f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 148f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 52f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 148f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_cross_max_height ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 10f ) ; <nl> + root_child0 . setMaxHeightPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 10f ) ; <nl> + root_child1 . setMaxHeightPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_main_max_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 15f ) ; <nl> + root_child0 . setMaxWidthPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 10f ) ; <nl> + root_child1 . setMaxWidthPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 120f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 80f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 40f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_cross_max_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 10f ) ; <nl> + root_child0 . setMaxWidthPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 15f ) ; <nl> + root_child1 . setMaxWidthPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 150f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 80f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 160f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 40f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 150f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_main_min_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setFlexDirection ( YogaFlexDirection . ROW ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 15f ) ; <nl> + root_child0 . setMinWidthPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 10f ) ; <nl> + root_child1 . setMinWidthPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 120f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 80f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 80f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 120f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 80f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_flex_basis_cross_min_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 10f ) ; <nl> + root_child0 . setMinWidthPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 15f ) ; <nl> + root_child1 . setMinWidthPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 150f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 50f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 150f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 200f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setFlexBasisPercent ( 10f ) ; <nl> + root_child0 . setMargin ( YogaEdge . LEFT , 5f ) ; <nl> + root_child0 . setMargin ( YogaEdge . TOP , 5f ) ; <nl> + root_child0 . setMargin ( YogaEdge . RIGHT , 5f ) ; <nl> + root_child0 . setMargin ( YogaEdge . BOTTOM , 5f ) ; <nl> + root_child0 . setPadding ( YogaEdge . LEFT , 3 ) ; <nl> + root_child0 . setPadding ( YogaEdge . TOP , 3 ) ; <nl> + root_child0 . setPadding ( YogaEdge . RIGHT , 3 ) ; <nl> + root_child0 . setPadding ( YogaEdge . BOTTOM , 3 ) ; <nl> + root_child0 . setMinWidthPercent ( 60f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . setMargin ( YogaEdge . LEFT , 5f ) ; <nl> + root_child0_child0 . setMargin ( YogaEdge . TOP , 5f ) ; <nl> + root_child0_child0 . setMargin ( YogaEdge . RIGHT , 5f ) ; <nl> + root_child0_child0 . setMargin ( YogaEdge . BOTTOM , 5f ) ; <nl> + root_child0_child0 . setPaddingPercent ( YogaEdge . LEFT , 3 ) ; <nl> + root_child0_child0 . setPaddingPercent ( YogaEdge . TOP , 3 ) ; <nl> + root_child0_child0 . setPaddingPercent ( YogaEdge . RIGHT , 3 ) ; <nl> + root_child0_child0 . setPaddingPercent ( YogaEdge . BOTTOM , 3 ) ; <nl> + root_child0_child0 . setWidthPercent ( 50f ) ; <nl> + root_child0 . addChildAt ( root_child0_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child0_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0_child0 . setMarginPercent ( YogaEdge . LEFT , 5f ) ; <nl> + root_child0_child0_child0 . setMarginPercent ( YogaEdge . TOP , 5f ) ; <nl> + root_child0_child0_child0 . setMarginPercent ( YogaEdge . RIGHT , 5f ) ; <nl> + root_child0_child0_child0 . setMarginPercent ( YogaEdge . BOTTOM , 5f ) ; <nl> + root_child0_child0_child0 . setPadding ( YogaEdge . LEFT , 3 ) ; <nl> + root_child0_child0_child0 . setPadding ( YogaEdge . TOP , 3 ) ; <nl> + root_child0_child0_child0 . setPadding ( YogaEdge . RIGHT , 3 ) ; <nl> + root_child0_child0_child0 . setPadding ( YogaEdge . BOTTOM , 3 ) ; <nl> + root_child0_child0_child0 . setWidthPercent ( 45f ) ; <nl> + root_child0_child0 . addChildAt ( root_child0_child0_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child1 = new YogaNode ( ) ; <nl> + root_child1 . setFlexGrow ( 4f ) ; <nl> + root_child1 . setFlexBasisPercent ( 15f ) ; <nl> + root_child1 . setMinWidthPercent ( 20f ) ; <nl> + root . addChildAt ( root_child1 , 1 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 5f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 5f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 190f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 48f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 8f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 8f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 92f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 25f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 10f , root_child0_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 36f , root_child0_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 6f , root_child0_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 58f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 142f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 5f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 5f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 190f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 48f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 90f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 8f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 92f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 25f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 46f , root_child0_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 36f , root_child0_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 6f , root_child0_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child1 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 58f , root_child1 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child1 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 142f , root_child1 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_margin_should_calculate_based_only_on_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 100f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setMarginPercent ( YogaEdge . LEFT , 10f ) ; <nl> + root_child0 . setMarginPercent ( YogaEdge . TOP , 10f ) ; <nl> + root_child0 . setMarginPercent ( YogaEdge . RIGHT , 10f ) ; <nl> + root_child0 . setMarginPercent ( YogaEdge . BOTTOM , 10f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . setWidth ( 10f ) ; <nl> + root_child0_child0 . setHeight ( 10f ) ; <nl> + root_child0 . addChildAt ( root_child0_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 20f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 20f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 160f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 20f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 20f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 160f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 60f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 150f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_padding_should_calculate_based_only_on_width ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 100f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setFlexGrow ( 1f ) ; <nl> + root_child0 . setPaddingPercent ( YogaEdge . LEFT , 10 ) ; <nl> + root_child0 . setPaddingPercent ( YogaEdge . TOP , 10 ) ; <nl> + root_child0 . setPaddingPercent ( YogaEdge . RIGHT , 10 ) ; <nl> + root_child0 . setPaddingPercent ( YogaEdge . BOTTOM , 10 ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + <nl> + final YogaNode root_child0_child0 = new YogaNode ( ) ; <nl> + root_child0_child0 . setWidth ( 10f ) ; <nl> + root_child0_child0 . setHeight ( 10f ) ; <nl> + root_child0 . addChildAt ( root_child0_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 20f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 20f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 0f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 170f , root_child0_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 20f , root_child0_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + @ Test <nl> + public void test_percentage_absolute_position ( ) { <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , true ) ; <nl> + <nl> + final YogaNode root = new YogaNode ( ) ; <nl> + root . setWidth ( 200f ) ; <nl> + root . setHeight ( 100f ) ; <nl> + <nl> + final YogaNode root_child0 = new YogaNode ( ) ; <nl> + root_child0 . setPositionType ( YogaPositionType . ABSOLUTE ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . LEFT , 30f ) ; <nl> + root_child0 . setPositionPercent ( YogaEdge . TOP , 10f ) ; <nl> + root_child0 . setWidth ( 10f ) ; <nl> + root_child0 . setHeight ( 10f ) ; <nl> + root . addChildAt ( root_child0 , 0 ) ; <nl> + root . setDirection ( YogaDirection . LTR ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 60f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + root . setDirection ( YogaDirection . RTL ) ; <nl> + root . calculateLayout ( ) ; <nl> + <nl> + assertEquals ( 0f , root . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 0f , root . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 200f , root . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 100f , root . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + assertEquals ( 60f , root_child0 . getLayoutX ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutY ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutWidth ( ) , 0 . 0f ) ; <nl> + assertEquals ( 10f , root_child0 . getLayoutHeight ( ) , 0 . 0f ) ; <nl> + <nl> + YogaNode . setExperimentalFeatureEnabled ( YogaExperimentalFeature . ROUNDING , false ) ; <nl> + } <nl> + <nl> + } <nl> mmm a / java / tests / com / facebook / yoga / YogaNodeTest . java <nl> ppp b / java / tests / com / facebook / yoga / YogaNodeTest . java <nl> public void testCopyStyle ( ) { <nl> node1 . setMaxHeight ( 100 ) ; <nl> <nl> node0 . copyStyle ( node1 ) ; <nl> - assertEquals ( 100 , ( int ) node0 . getMaxHeight ( ) ) ; <nl> + assertEquals ( 100 , ( int ) node0 . getMaxHeight ( ) . value ) ; <nl> } <nl> } <nl> mmm a / tests / YGDefaultValuesTest . cpp <nl> ppp b / tests / YGDefaultValuesTest . cpp <nl> TEST ( YogaTest , assert_default_values ) { <nl> ASSERT_EQ ( YGOverflowVisible , YGNodeStyleGetOverflow ( root ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetFlexGrow ( root ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetFlexShrink ( root ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetFlexBasis ( root ) ) ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetFlexBasis ( root ) . unit ! = YGUnitUndefined ) ; <nl> <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeLeft ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeTop ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeRight ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeBottom ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeStart ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPosition ( root , YGEdgeEnd ) ) ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeLeft ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeTop ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeRight ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeBottom ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeStart ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPosition ( root , YGEdgeEnd ) . unit ! = YGUnitUndefined ) ; <nl> <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeLeft ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeTop ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeRight ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeBottom ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMargin ( root , YGEdgeStart ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMargin ( root , YGEdgeEnd ) ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeLeft ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeTop ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeRight ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetMargin ( root , YGEdgeBottom ) . value ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMargin ( root , YGEdgeStart ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMargin ( root , YGEdgeEnd ) . unit ! = YGUnitUndefined ) ; <nl> <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeLeft ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeTop ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeRight ) ) ; <nl> - ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeBottom ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPadding ( root , YGEdgeStart ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetPadding ( root , YGEdgeEnd ) ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeLeft ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeTop ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeRight ) . value ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetPadding ( root , YGEdgeBottom ) . value ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPadding ( root , YGEdgeStart ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetPadding ( root , YGEdgeEnd ) . unit ! = YGUnitUndefined ) ; <nl> <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetBorder ( root , YGEdgeLeft ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetBorder ( root , YGEdgeTop ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetBorder ( root , YGEdgeRight ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeStyleGetBorder ( root , YGEdgeBottom ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetBorder ( root , YGEdgeStart ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetBorder ( root , YGEdgeEnd ) ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( YGNodeStyleGetBorder ( root , YGEdgeStart ) ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( YGNodeStyleGetBorder ( root , YGEdgeEnd ) ) ) ; <nl> <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetWidth ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetHeight ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMinWidth ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMinHeight ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMaxWidth ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMaxHeight ( root ) ) ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetWidth ( root ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetHeight ( root ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMinWidth ( root ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMinHeight ( root ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMaxWidth ( root ) . unit ! = YGUnitUndefined ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMaxHeight ( root ) . unit ! = YGUnitUndefined ) ; <nl> <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetRight ( root ) ) ; <nl> ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetBottom ( root ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeLayoutGetWidth ( root ) ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeLayoutGetHeight ( root ) ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( YGNodeLayoutGetWidth ( root ) ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( YGNodeLayoutGetHeight ( root ) ) ) ; <nl> ASSERT_EQ ( YGDirectionInherit , YGNodeLayoutGetDirection ( root ) ) ; <nl> <nl> YGNodeFreeRecursive ( root ) ; <nl> mmm a / tests / YGMeasureModeTest . cpp <nl> ppp b / tests / YGMeasureModeTest . cpp <nl> TEST ( YogaTest , overflow_scroll_column ) { <nl> ASSERT_FLOAT_EQ ( 100 , constraintList . constraints [ 0 ] . width ) ; <nl> ASSERT_EQ ( YGMeasureModeAtMost , constraintList . constraints [ 0 ] . widthMode ) ; <nl> <nl> - ASSERT_TRUE ( YGValueIsUndefined ( constraintList . constraints [ 0 ] . height ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( constraintList . constraints [ 0 ] . height ) ) ; <nl> ASSERT_EQ ( YGMeasureModeUndefined , constraintList . constraints [ 0 ] . heightMode ) ; <nl> <nl> free ( constraintList . constraints ) ; <nl> TEST ( YogaTest , overflow_scroll_row ) { <nl> <nl> ASSERT_EQ ( 1 , constraintList . length ) ; <nl> <nl> - ASSERT_TRUE ( YGValueIsUndefined ( constraintList . constraints [ 0 ] . width ) ) ; <nl> + ASSERT_TRUE ( YGFloatIsUndefined ( constraintList . constraints [ 0 ] . width ) ) ; <nl> ASSERT_EQ ( YGMeasureModeUndefined , constraintList . constraints [ 0 ] . widthMode ) ; <nl> <nl> ASSERT_FLOAT_EQ ( 100 , constraintList . constraints [ 0 ] . height ) ; <nl> new file mode 100644 <nl> index 000000000 . . 80d2f4f73 <nl> mmm / dev / null <nl> ppp b / tests / YGPercentageTest . cpp <nl> <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> + <nl> + / / @ Generated by gentest / gentest . rb from gentest / fixtures / YGPercentageTest . html <nl> + <nl> + # include < yoga / Yoga . h > <nl> + # include < gtest / gtest . h > <nl> + <nl> + TEST ( YogaTest , percentage_width_height ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidthPercent ( root_child0 , 30 ) ; <nl> + YGNodeStyleSetHeightPercent ( root_child0 , 30 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 140 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_position_left_top ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 400 ) ; <nl> + YGNodeStyleSetHeight ( root , 400 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeLeft , 10 ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeTop , 20 ) ; <nl> + YGNodeStyleSetWidthPercent ( root_child0 , 45 ) ; <nl> + YGNodeStyleSetHeightPercent ( root_child0 , 55 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 400 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 400 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 180 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 220 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 400 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 400 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 260 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 180 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 220 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_position_bottom_right ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 500 ) ; <nl> + YGNodeStyleSetHeight ( root , 500 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeRight , 20 ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeBottom , 10 ) ; <nl> + YGNodeStyleSetWidthPercent ( root_child0 , 55 ) ; <nl> + YGNodeStyleSetHeightPercent ( root_child0 , 15 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 500 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 500 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( - 100 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( - 50 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 275 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 500 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 500 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( - 50 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 275 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 50 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 25 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_cross ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 50 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 25 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 125 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 75 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_cross_min_height ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetMinHeightPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 2 ) ; <nl> + YGNodeStyleSetMinHeightPercent ( root_child1 , 10 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 140 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 140 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 140 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 140 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_main_max_height ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetMaxHeightPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 10 ) ; <nl> + YGNodeStyleSetMaxHeightPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 52 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 52 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 148 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 148 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 52 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 148 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_cross_max_height ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetMaxHeightPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 10 ) ; <nl> + YGNodeStyleSetMaxHeightPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_main_max_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 15 ) ; <nl> + YGNodeStyleSetMaxWidthPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 10 ) ; <nl> + YGNodeStyleSetMaxWidthPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_cross_max_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetMaxWidthPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 15 ) ; <nl> + YGNodeStyleSetMaxWidthPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 150 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 160 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 40 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 150 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_main_min_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexDirection ( root , YGFlexDirectionRow ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 15 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 10 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 120 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 80 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_flex_basis_cross_min_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 15 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 150 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 50 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 150 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_multiple_nested_with_padding_margin_and_percentage_values ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 200 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetMargin ( root_child0 , YGEdgeLeft , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0 , YGEdgeTop , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0 , YGEdgeRight , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0 , YGEdgeBottom , 5 ) ; <nl> + YGNodeStyleSetPadding ( root_child0 , YGEdgeLeft , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0 , YGEdgeTop , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0 , YGEdgeRight , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0 , YGEdgeBottom , 3 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child0 , 60 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child0_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetMargin ( root_child0_child0 , YGEdgeLeft , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0_child0 , YGEdgeTop , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0_child0 , YGEdgeRight , 5 ) ; <nl> + YGNodeStyleSetMargin ( root_child0_child0 , YGEdgeBottom , 5 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0_child0 , YGEdgeLeft , 3 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0_child0 , YGEdgeTop , 3 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0_child0 , YGEdgeRight , 3 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0_child0 , YGEdgeBottom , 3 ) ; <nl> + YGNodeStyleSetWidthPercent ( root_child0_child0 , 50 ) ; <nl> + YGNodeInsertChild ( root_child0 , root_child0_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child0_child0_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0_child0_child0 , YGEdgeLeft , 5 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0_child0_child0 , YGEdgeTop , 5 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0_child0_child0 , YGEdgeRight , 5 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0_child0_child0 , YGEdgeBottom , 5 ) ; <nl> + YGNodeStyleSetPadding ( root_child0_child0_child0 , YGEdgeLeft , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0_child0_child0 , YGEdgeTop , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0_child0_child0 , YGEdgeRight , 3 ) ; <nl> + YGNodeStyleSetPadding ( root_child0_child0_child0 , YGEdgeBottom , 3 ) ; <nl> + YGNodeStyleSetWidthPercent ( root_child0_child0_child0 , 45 ) ; <nl> + YGNodeInsertChild ( root_child0_child0 , root_child0_child0_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child1 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child1 , 4 ) ; <nl> + YGNodeStyleSetFlexBasisPercent ( root_child1 , 15 ) ; <nl> + YGNodeStyleSetMinWidthPercent ( root_child1 , 20 ) ; <nl> + YGNodeInsertChild ( root , root_child1 , 1 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 5 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 5 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 190 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 48 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 8 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 8 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 92 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 25 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetLeft ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetTop ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 36 , YGNodeLayoutGetWidth ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 6 , YGNodeLayoutGetHeight ( root_child0_child0_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 58 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 142 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 5 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 5 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 190 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 48 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 90 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 8 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 92 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 25 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 46 , YGNodeLayoutGetLeft ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetTop ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 36 , YGNodeLayoutGetWidth ( root_child0_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 6 , YGNodeLayoutGetHeight ( root_child0_child0_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 58 , YGNodeLayoutGetTop ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child1 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 142 , YGNodeLayoutGetHeight ( root_child1 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_margin_should_calculate_based_only_on_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 100 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0 , YGEdgeLeft , 10 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0 , YGEdgeTop , 10 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0 , YGEdgeRight , 10 ) ; <nl> + YGNodeStyleSetMarginPercent ( root_child0 , YGEdgeBottom , 10 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child0_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root_child0_child0 , 10 ) ; <nl> + YGNodeStyleSetHeight ( root_child0_child0 , 10 ) ; <nl> + YGNodeInsertChild ( root_child0 , root_child0_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 160 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 160 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 150 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_padding_should_calculate_based_only_on_width ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 100 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetFlexGrow ( root_child0 , 1 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0 , YGEdgeLeft , 10 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0 , YGEdgeTop , 10 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0 , YGEdgeRight , 10 ) ; <nl> + YGNodeStyleSetPaddingPercent ( root_child0 , YGEdgeBottom , 10 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + <nl> + const YGNodeRef root_child0_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root_child0_child0 , 10 ) ; <nl> + YGNodeStyleSetHeight ( root_child0_child0 , 10 ) ; <nl> + YGNodeInsertChild ( root_child0 , root_child0_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 170 , YGNodeLayoutGetLeft ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 20 , YGNodeLayoutGetTop ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> + <nl> + TEST ( YogaTest , percentage_absolute_position ) { <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , true ) ; <nl> + <nl> + const YGNodeRef root = YGNodeNew ( ) ; <nl> + YGNodeStyleSetWidth ( root , 200 ) ; <nl> + YGNodeStyleSetHeight ( root , 100 ) ; <nl> + <nl> + const YGNodeRef root_child0 = YGNodeNew ( ) ; <nl> + YGNodeStyleSetPositionType ( root_child0 , YGPositionTypeAbsolute ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeLeft , 30 ) ; <nl> + YGNodeStyleSetPositionPercent ( root_child0 , YGEdgeTop , 10 ) ; <nl> + YGNodeStyleSetWidth ( root_child0 , 10 ) ; <nl> + YGNodeStyleSetHeight ( root_child0 , 10 ) ; <nl> + YGNodeInsertChild ( root , root_child0 , 0 ) ; <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionLTR ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeCalculateLayout ( root , YGUndefined , YGUndefined , YGDirectionRTL ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetLeft ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 0 , YGNodeLayoutGetTop ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 200 , YGNodeLayoutGetWidth ( root ) ) ; <nl> + ASSERT_FLOAT_EQ ( 100 , YGNodeLayoutGetHeight ( root ) ) ; <nl> + <nl> + ASSERT_FLOAT_EQ ( 60 , YGNodeLayoutGetLeft ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetTop ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetWidth ( root_child0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeLayoutGetHeight ( root_child0 ) ) ; <nl> + <nl> + YGNodeFreeRecursive ( root ) ; <nl> + <nl> + YGSetExperimentalFeatureEnabled ( YGExperimentalFeatureRounding , false ) ; <nl> + } <nl> mmm a / tests / YGStyleTest . cpp <nl> ppp b / tests / YGStyleTest . cpp <nl> TEST ( YogaTest , copy_style_modified ) { <nl> const YGNodeRef node0 = YGNodeNew ( ) ; <nl> ASSERT_FALSE ( YGNodeIsDirty ( node0 ) ) ; <nl> ASSERT_EQ ( YGFlexDirectionColumn , YGNodeStyleGetFlexDirection ( node0 ) ) ; <nl> - ASSERT_TRUE ( YGValueIsUndefined ( YGNodeStyleGetMaxHeight ( node0 ) ) ) ; <nl> + ASSERT_FALSE ( YGNodeStyleGetMaxHeight ( node0 ) . unit ! = YGUnitUndefined ) ; <nl> <nl> const YGNodeRef node1 = YGNodeNew ( ) ; <nl> YGNodeStyleSetFlexDirection ( node1 , YGFlexDirectionRow ) ; <nl> TEST ( YogaTest , copy_style_modified ) { <nl> YGNodeCopyStyle ( node0 , node1 ) ; <nl> ASSERT_TRUE ( YGNodeIsDirty ( node0 ) ) ; <nl> ASSERT_EQ ( YGFlexDirectionRow , YGNodeStyleGetFlexDirection ( node0 ) ) ; <nl> - ASSERT_FLOAT_EQ ( 10 , YGNodeStyleGetMaxHeight ( node0 ) ) ; <nl> + ASSERT_FLOAT_EQ ( 10 , YGNodeStyleGetMaxHeight ( node0 ) . value ) ; <nl> <nl> YGNodeFree ( node0 ) ; <nl> YGNodeFree ( node1 ) ; <nl> mmm a / yoga / YGEnums . h <nl> ppp b / yoga / YGEnums . h <nl> typedef enum YGAlign { <nl> YGAlignStretch , <nl> } YGAlign ; <nl> <nl> + # define YGUnitCount 3 <nl> + typedef enum YGUnit { <nl> + YGUnitUndefined , <nl> + YGUnitPixel , <nl> + YGUnitPercent , <nl> + } YGUnit ; <nl> + <nl> YG_EXTERN_C_END <nl> mmm a / yoga / Yoga . c <nl> ppp b / yoga / Yoga . c <nl> typedef struct YGStyle { <nl> float flex ; <nl> float flexGrow ; <nl> float flexShrink ; <nl> - float flexBasis ; <nl> - float margin [ YGEdgeCount ] ; <nl> - float position [ YGEdgeCount ] ; <nl> - float padding [ YGEdgeCount ] ; <nl> - float border [ YGEdgeCount ] ; <nl> - float dimensions [ 2 ] ; <nl> - float minDimensions [ 2 ] ; <nl> - float maxDimensions [ 2 ] ; <nl> + YGValue flexBasis ; <nl> + YGValue margin [ YGEdgeCount ] ; <nl> + YGValue position [ YGEdgeCount ] ; <nl> + YGValue padding [ YGEdgeCount ] ; <nl> + YGValue border [ YGEdgeCount ] ; <nl> + YGValue dimensions [ 2 ] ; <nl> + YGValue minDimensions [ 2 ] ; <nl> + YGValue maxDimensions [ 2 ] ; <nl> <nl> / / Yoga specific properties , not compatible with flexbox specification <nl> float aspectRatio ; <nl> typedef struct YGNode { <nl> void * context ; <nl> } YGNode ; <nl> <nl> - # define YG_DEFAULT_EDGE_VALUES { \ <nl> - [ YGEdgeLeft ] = YGUndefined , \ <nl> - [ YGEdgeTop ] = YGUndefined , \ <nl> - [ YGEdgeRight ] = YGUndefined , \ <nl> - [ YGEdgeBottom ] = YGUndefined , \ <nl> - [ YGEdgeStart ] = YGUndefined , \ <nl> - [ YGEdgeEnd ] = YGUndefined , \ <nl> - [ YGEdgeHorizontal ] = YGUndefined , \ <nl> - [ YGEdgeVertical ] = YGUndefined , \ <nl> - [ YGEdgeAll ] = YGUndefined , \ <nl> - } <nl> - <nl> - # define YG_DEFAULT_DIMENSION_VALUES { \ <nl> - [ YGDimensionWidth ] = YGUndefined , \ <nl> - [ YGDimensionHeight ] = YGUndefined , \ <nl> - } <nl> - <nl> - YGNode gYGNodeDefaults = { <nl> - . parent = NULL , <nl> - . children = NULL , <nl> - . hasNewLayout = true , <nl> - . isDirty = false , <nl> - <nl> - . style = { <nl> - . flex = YGUndefined , <nl> - . flexGrow = YGUndefined , <nl> - . flexShrink = YGUndefined , <nl> - . flexBasis = YGUndefined , <nl> - . justifyContent = YGJustifyFlexStart , <nl> - . alignItems = YGAlignStretch , <nl> - . alignContent = YGAlignFlexStart , <nl> - . direction = YGDirectionInherit , <nl> - . flexDirection = YGFlexDirectionColumn , <nl> - . overflow = YGOverflowVisible , <nl> - . dimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> - . minDimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> - . maxDimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> - . position = YG_DEFAULT_EDGE_VALUES , <nl> - . margin = YG_DEFAULT_EDGE_VALUES , <nl> - . padding = YG_DEFAULT_EDGE_VALUES , <nl> - . border = YG_DEFAULT_EDGE_VALUES , <nl> - . aspectRatio = YGUndefined , <nl> - } , <nl> - <nl> - . layout = { <nl> - . dimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> - . lastParentDirection = ( YGDirection ) - 1 , <nl> - . nextCachedMeasurementsIndex = 0 , <nl> - . computedFlexBasis = YGUndefined , <nl> - . measuredDimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> - <nl> - . cachedLayout = { <nl> - . widthMeasureMode = ( YGMeasureMode ) - 1 , <nl> - . heightMeasureMode = ( YGMeasureMode ) - 1 , <nl> - . computedWidth = - 1 , <nl> - . computedHeight = - 1 , <nl> - } , <nl> - } , <nl> + # define YG_UNDEFINED_VALUES \ <nl> + { . value = YGUndefined , . unit = YGUnitUndefined } <nl> + <nl> + # define YG_DEFAULT_EDGE_VALUES_UNIT \ <nl> + { \ <nl> + [ YGEdgeLeft ] = YG_UNDEFINED_VALUES , [ YGEdgeTop ] = YG_UNDEFINED_VALUES , \ <nl> + [ YGEdgeRight ] = YG_UNDEFINED_VALUES , [ YGEdgeBottom ] = YG_UNDEFINED_VALUES , \ <nl> + [ YGEdgeStart ] = YG_UNDEFINED_VALUES , [ YGEdgeEnd ] = YG_UNDEFINED_VALUES , \ <nl> + [ YGEdgeHorizontal ] = YG_UNDEFINED_VALUES , [ YGEdgeVertical ] = YG_UNDEFINED_VALUES , \ <nl> + [ YGEdgeAll ] = YG_UNDEFINED_VALUES , \ <nl> + } <nl> + <nl> + # define YG_DEFAULT_DIMENSION_VALUES \ <nl> + { [ YGDimensionWidth ] = YGUndefined , [ YGDimensionHeight ] = YGUndefined , } <nl> + <nl> + # define YG_DEFAULT_DIMENSION_VALUES_UNIT \ <nl> + { [ YGDimensionWidth ] = YG_UNDEFINED_VALUES , [ YGDimensionHeight ] = YG_UNDEFINED_VALUES , } <nl> + <nl> + static YGNode gYGNodeDefaults = { <nl> + . parent = NULL , <nl> + . children = NULL , <nl> + . hasNewLayout = true , <nl> + . isDirty = false , <nl> + <nl> + . style = <nl> + { <nl> + . flex = YGUndefined , <nl> + . flexGrow = YGUndefined , <nl> + . flexShrink = YGUndefined , <nl> + . flexBasis = YG_UNDEFINED_VALUES , <nl> + . justifyContent = YGJustifyFlexStart , <nl> + . alignItems = YGAlignStretch , <nl> + . alignContent = YGAlignFlexStart , <nl> + . direction = YGDirectionInherit , <nl> + . flexDirection = YGFlexDirectionColumn , <nl> + . overflow = YGOverflowVisible , <nl> + . dimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT , <nl> + . minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT , <nl> + . maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT , <nl> + . position = YG_DEFAULT_EDGE_VALUES_UNIT , <nl> + . margin = YG_DEFAULT_EDGE_VALUES_UNIT , <nl> + . padding = YG_DEFAULT_EDGE_VALUES_UNIT , <nl> + . border = YG_DEFAULT_EDGE_VALUES_UNIT , <nl> + . aspectRatio = YGUndefined , <nl> + } , <nl> + <nl> + . layout = <nl> + { <nl> + . dimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> + . lastParentDirection = ( YGDirection ) - 1 , <nl> + . nextCachedMeasurementsIndex = 0 , <nl> + . computedFlexBasis = YGUndefined , <nl> + . measuredDimensions = YG_DEFAULT_DIMENSION_VALUES , <nl> + <nl> + . cachedLayout = <nl> + { <nl> + . widthMeasureMode = ( YGMeasureMode ) - 1 , <nl> + . heightMeasureMode = ( YGMeasureMode ) - 1 , <nl> + . computedWidth = - 1 , <nl> + . computedHeight = - 1 , <nl> + } , <nl> + } , <nl> } ; <nl> <nl> static void YGNodeMarkDirtyInternal ( const YGNodeRef node ) ; <nl> YGCalloc gYGCalloc = & calloc ; <nl> YGRealloc gYGRealloc = & realloc ; <nl> YGFree gYGFree = & free ; <nl> <nl> + static YGValue YGValueUndefined = YG_UNDEFINED_VALUES ; <nl> + <nl> + static YGValue YGValueZero = { . value = 0 , . unit = YGUnitPixel } ; <nl> + <nl> # ifdef ANDROID <nl> # include < android / log . h > <nl> static int YGAndroidLog ( YGLogLevel level , const char * format , va_list args ) { <nl> static int YGDefaultLog ( YGLogLevel level , const char * format , va_list args ) { <nl> static YGLogger gLogger = & YGDefaultLog ; <nl> # endif <nl> <nl> - static inline float YGComputedEdgeValue ( const float edges [ YGEdgeCount ] , <nl> - const YGEdge edge , <nl> - const float defaultValue ) { <nl> + static inline const YGValue * YGComputedEdgeValue ( const YGValue edges [ YGEdgeCount ] , <nl> + const YGEdge edge , <nl> + const YGValue * const defaultValue ) { <nl> YG_ASSERT ( edge < = YGEdgeEnd , " Cannot get computed value of multi - edge shorthands " ) ; <nl> <nl> - if ( ! YGValueIsUndefined ( edges [ edge ] ) ) { <nl> - return edges [ edge ] ; <nl> + if ( edges [ edge ] . unit ! = YGUnitUndefined ) { <nl> + return & edges [ edge ] ; <nl> } <nl> <nl> - if ( ( edge = = YGEdgeTop | | edge = = YGEdgeBottom ) & & ! YGValueIsUndefined ( edges [ YGEdgeVertical ] ) ) { <nl> - return edges [ YGEdgeVertical ] ; <nl> + if ( ( edge = = YGEdgeTop | | edge = = YGEdgeBottom ) & & <nl> + edges [ YGEdgeVertical ] . unit ! = YGUnitUndefined ) { <nl> + return & edges [ YGEdgeVertical ] ; <nl> } <nl> <nl> if ( ( edge = = YGEdgeLeft | | edge = = YGEdgeRight | | edge = = YGEdgeStart | | edge = = YGEdgeEnd ) & & <nl> - ! YGValueIsUndefined ( edges [ YGEdgeHorizontal ] ) ) { <nl> - return edges [ YGEdgeHorizontal ] ; <nl> + edges [ YGEdgeHorizontal ] . unit ! = YGUnitUndefined ) { <nl> + return & edges [ YGEdgeHorizontal ] ; <nl> } <nl> <nl> - if ( ! YGValueIsUndefined ( edges [ YGEdgeAll ] ) ) { <nl> - return edges [ YGEdgeAll ] ; <nl> + if ( edges [ YGEdgeAll ] . unit ! = YGUnitUndefined ) { <nl> + return & edges [ YGEdgeAll ] ; <nl> } <nl> <nl> if ( edge = = YGEdgeStart | | edge = = YGEdgeEnd ) { <nl> - return YGUndefined ; <nl> + return & YGValueUndefined ; <nl> } <nl> <nl> return defaultValue ; <nl> } <nl> <nl> + static inline float YGValueResolve ( const YGValue * const unit , const float parentSize ) { <nl> + if ( unit - > unit = = YGUnitPixel ) { <nl> + return unit - > value ; <nl> + } else { <nl> + return unit - > value * parentSize / 100 . 0f ; <nl> + } <nl> + } <nl> + <nl> int32_t gNodeInstanceCount = 0 ; <nl> <nl> YGNodeRef YGNodeNew ( void ) { <nl> void YGNodeFreeRecursive ( const YGNodeRef root ) { <nl> } <nl> <nl> void YGNodeReset ( const YGNodeRef node ) { <nl> - YG_ASSERT ( YGNodeGetChildCount ( node ) = = 0 , " Cannot reset a node which still has children attached " ) ; <nl> + YG_ASSERT ( YGNodeGetChildCount ( node ) = = 0 , <nl> + " Cannot reset a node which still has children attached " ) ; <nl> YG_ASSERT ( node - > parent = = NULL , " Cannot reset a node still attached to a parent " ) ; <nl> <nl> YGNodeListFree ( node - > children ) ; <nl> void YGNodeCopyStyle ( const YGNodeRef dstNode , const YGNodeRef srcNode ) { <nl> } <nl> <nl> inline float YGNodeStyleGetFlexGrow ( const YGNodeRef node ) { <nl> - if ( ! YGValueIsUndefined ( node - > style . flexGrow ) ) { <nl> + if ( ! YGFloatIsUndefined ( node - > style . flexGrow ) ) { <nl> return node - > style . flexGrow ; <nl> } <nl> - if ( ! YGValueIsUndefined ( node - > style . flex ) & & node - > style . flex > 0 ) { <nl> + if ( ! YGFloatIsUndefined ( node - > style . flex ) & & node - > style . flex > 0 . 0f ) { <nl> return node - > style . flex ; <nl> } <nl> - return 0 ; <nl> + return 0 . 0f ; <nl> } <nl> <nl> inline float YGNodeStyleGetFlexShrink ( const YGNodeRef node ) { <nl> - if ( ! YGValueIsUndefined ( node - > style . flexShrink ) ) { <nl> + if ( ! YGFloatIsUndefined ( node - > style . flexShrink ) ) { <nl> return node - > style . flexShrink ; <nl> } <nl> - if ( ! YGValueIsUndefined ( node - > style . flex ) & & node - > style . flex < 0 ) { <nl> + if ( ! YGFloatIsUndefined ( node - > style . flex ) & & node - > style . flex < 0 . 0f ) { <nl> return - node - > style . flex ; <nl> } <nl> - return 0 ; <nl> + return 0 . 0f ; <nl> } <nl> <nl> - inline float YGNodeStyleGetFlexBasis ( const YGNodeRef node ) { <nl> - if ( ! YGValueIsUndefined ( node - > style . flexBasis ) ) { <nl> - return node - > style . flexBasis ; <nl> + static inline const YGValue * YGNodeStyleGetFlexBasisPtr ( const YGNodeRef node ) { <nl> + if ( node - > style . flexBasis . unit ! = YGUnitUndefined ) { <nl> + return & node - > style . flexBasis ; <nl> } <nl> - if ( ! YGValueIsUndefined ( node - > style . flex ) ) { <nl> - return node - > style . flex > 0 ? 0 : YGUndefined ; <nl> + if ( ! YGFloatIsUndefined ( node - > style . flex ) & & node - > style . flex > 0 . 0f ) { <nl> + return & YGValueZero ; <nl> } <nl> - return YGUndefined ; <nl> + return & YGValueUndefined ; <nl> + } <nl> + <nl> + inline YGValue YGNodeStyleGetFlexBasis ( const YGNodeRef node ) { <nl> + return * YGNodeStyleGetFlexBasisPtr ( node ) ; <nl> } <nl> <nl> void YGNodeStyleSetFlex ( const YGNodeRef node , const float flex ) { <nl> void YGNodeStyleSetFlex ( const YGNodeRef node , const float flex ) { <nl> } \ <nl> } <nl> <nl> + # define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL ( type , name , paramName , instanceName ) \ <nl> + void YGNodeStyleSet # # name ( const YGNodeRef node , const type paramName ) { \ <nl> + if ( node - > style . instanceName . value ! = paramName | | \ <nl> + node - > style . instanceName . unit ! = YGUnitPixel ) { \ <nl> + node - > style . instanceName . value = paramName ; \ <nl> + node - > style . instanceName . unit = \ <nl> + YGFloatIsUndefined ( paramName ) ? YGUnitUndefined : YGUnitPixel ; \ <nl> + YGNodeMarkDirtyInternal ( node ) ; \ <nl> + } \ <nl> + } \ <nl> + \ <nl> + void YGNodeStyleSet # # name # # Percent ( const YGNodeRef node , const type paramName ) { \ <nl> + if ( node - > style . instanceName . value ! = paramName | | \ <nl> + node - > style . instanceName . unit ! = YGUnitPercent ) { \ <nl> + node - > style . instanceName . value = paramName ; \ <nl> + node - > style . instanceName . unit = \ <nl> + YGFloatIsUndefined ( paramName ) ? YGUnitUndefined : YGUnitPercent ; \ <nl> + YGNodeMarkDirtyInternal ( node ) ; \ <nl> + } \ <nl> + } <nl> + <nl> # define YG_NODE_STYLE_PROPERTY_IMPL ( type , name , paramName , instanceName ) \ <nl> YG_NODE_STYLE_PROPERTY_SETTER_IMPL ( type , name , paramName , instanceName ) \ <nl> \ <nl> void YGNodeStyleSetFlex ( const YGNodeRef node , const float flex ) { <nl> return node - > style . instanceName ; \ <nl> } <nl> <nl> - # define YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( type , name , paramName , instanceName , defaultValue ) \ <nl> - void YGNodeStyleSet # # name ( const YGNodeRef node , const YGEdge edge , const type paramName ) { \ <nl> - if ( node - > style . instanceName [ edge ] ! = paramName ) { \ <nl> - node - > style . instanceName [ edge ] = paramName ; \ <nl> - YGNodeMarkDirtyInternal ( node ) ; \ <nl> - } \ <nl> - } \ <nl> - \ <nl> - type YGNodeStyleGet # # name ( const YGNodeRef node , const YGEdge edge ) { \ <nl> - return YGComputedEdgeValue ( node - > style . instanceName , edge , defaultValue ) ; \ <nl> + # define YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( type , name , paramName , instanceName ) \ <nl> + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL ( float , name , paramName , instanceName ) \ <nl> + \ <nl> + type YGNodeStyleGet # # name ( const YGNodeRef node ) { \ <nl> + return node - > style . instanceName ; \ <nl> + } <nl> + <nl> + # define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL ( type , name , paramName , instanceName , defaultValue ) \ <nl> + void YGNodeStyleSet # # name ( const YGNodeRef node , const YGEdge edge , const float paramName ) { \ <nl> + if ( node - > style . instanceName [ edge ] . value ! = paramName | | \ <nl> + node - > style . instanceName [ edge ] . unit ! = YGUnitPixel ) { \ <nl> + node - > style . instanceName [ edge ] . value = paramName ; \ <nl> + node - > style . instanceName [ edge ] . unit = \ <nl> + YGFloatIsUndefined ( paramName ) ? YGUnitUndefined : YGUnitPixel ; \ <nl> + YGNodeMarkDirtyInternal ( node ) ; \ <nl> + } \ <nl> + } \ <nl> + \ <nl> + void YGNodeStyleSet # # name # # Percent ( const YGNodeRef node , \ <nl> + const YGEdge edge , \ <nl> + const float paramName ) { \ <nl> + if ( node - > style . instanceName [ edge ] . value ! = paramName | | \ <nl> + node - > style . instanceName [ edge ] . unit ! = YGUnitPercent ) { \ <nl> + node - > style . instanceName [ edge ] . value = paramName ; \ <nl> + node - > style . instanceName [ edge ] . unit = \ <nl> + YGFloatIsUndefined ( paramName ) ? YGUnitUndefined : YGUnitPercent ; \ <nl> + YGNodeMarkDirtyInternal ( node ) ; \ <nl> + } \ <nl> + } \ <nl> + \ <nl> + type YGNodeStyleGet # # name ( const YGNodeRef node , const YGEdge edge ) { \ <nl> + return * YGComputedEdgeValue ( node - > style . instanceName , edge , & defaultValue ) ; \ <nl> + } <nl> + <nl> + # define YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( type , name , paramName , instanceName , defaultValue ) \ <nl> + void YGNodeStyleSet # # name ( const YGNodeRef node , const YGEdge edge , const float paramName ) { \ <nl> + if ( node - > style . instanceName [ edge ] . value ! = paramName | | \ <nl> + node - > style . instanceName [ edge ] . unit ! = YGUnitPixel ) { \ <nl> + node - > style . instanceName [ edge ] . value = paramName ; \ <nl> + node - > style . instanceName [ edge ] . unit = \ <nl> + YGFloatIsUndefined ( paramName ) ? YGUnitUndefined : YGUnitPixel ; \ <nl> + YGNodeMarkDirtyInternal ( node ) ; \ <nl> + } \ <nl> + } \ <nl> + \ <nl> + float YGNodeStyleGet # # name ( const YGNodeRef node , const YGEdge edge ) { \ <nl> + return YGComputedEdgeValue ( node - > style . instanceName , edge , & defaultValue ) - > value ; \ <nl> } <nl> <nl> # define YG_NODE_LAYOUT_PROPERTY_IMPL ( type , name , instanceName ) \ <nl> YG_NODE_STYLE_PROPERTY_IMPL ( YGOverflow , Overflow , overflow , overflow ) ; <nl> <nl> YG_NODE_STYLE_PROPERTY_SETTER_IMPL ( float , FlexGrow , flexGrow , flexGrow ) ; <nl> YG_NODE_STYLE_PROPERTY_SETTER_IMPL ( float , FlexShrink , flexShrink , flexShrink ) ; <nl> - YG_NODE_STYLE_PROPERTY_SETTER_IMPL ( float , FlexBasis , flexBasis , flexBasis ) ; <nl> + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL ( float , FlexBasis , flexBasis , flexBasis ) ; <nl> <nl> - YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( float , Position , position , position , YGUndefined ) ; <nl> - YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( float , Margin , margin , margin , 0 ) ; <nl> - YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( float , Padding , padding , padding , 0 ) ; <nl> - YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( float , Border , border , border , 0 ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL ( YGValue , Position , position , position , YGValueUndefined ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL ( YGValue , Margin , margin , margin , YGValueZero ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL ( YGValue , Padding , padding , padding , YGValueZero ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_IMPL ( float , Border , border , border , YGValueZero ) ; <nl> <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , Width , width , dimensions [ YGDimensionWidth ] ) ; <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , Height , height , dimensions [ YGDimensionHeight ] ) ; <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , MinWidth , minWidth , minDimensions [ YGDimensionWidth ] ) ; <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , MinHeight , minHeight , minDimensions [ YGDimensionHeight ] ) ; <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , MaxWidth , maxWidth , maxDimensions [ YGDimensionWidth ] ) ; <nl> - YG_NODE_STYLE_PROPERTY_IMPL ( float , MaxHeight , maxHeight , maxDimensions [ YGDimensionHeight ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , Width , width , dimensions [ YGDimensionWidth ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , Height , height , dimensions [ YGDimensionHeight ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , MinWidth , minWidth , minDimensions [ YGDimensionWidth ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , MinHeight , minHeight , minDimensions [ YGDimensionHeight ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , MaxWidth , maxWidth , maxDimensions [ YGDimensionWidth ] ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT_IMPL ( YGValue , MaxHeight , maxHeight , maxDimensions [ YGDimensionHeight ] ) ; <nl> <nl> / / Yoga specific properties , not compatible with flexbox specification <nl> YG_NODE_STYLE_PROPERTY_IMPL ( float , AspectRatio , aspectRatio , aspectRatio ) ; <nl> bool YGLayoutNodeInternal ( const YGNodeRef node , <nl> const YGDirection parentDirection , <nl> const YGMeasureMode widthMeasureMode , <nl> const YGMeasureMode heightMeasureMode , <nl> + const float parentWidth , <nl> + const float parentHeight , <nl> const bool performLayout , <nl> const char * reason ) ; <nl> <nl> - inline bool YGValueIsUndefined ( const float value ) { <nl> + inline bool YGFloatIsUndefined ( const float value ) { <nl> return isnan ( value ) ; <nl> } <nl> <nl> + static inline bool YGValueEqual ( const YGValue a , const YGValue b ) { <nl> + if ( a . unit ! = b . unit ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( a . unit = = YGUnitUndefined ) { <nl> + return true ; <nl> + } <nl> + <nl> + return fabs ( a . value - b . value ) < 0 . 0001f ; <nl> + } <nl> + <nl> static inline bool YGFloatsEqual ( const float a , const float b ) { <nl> - if ( YGValueIsUndefined ( a ) ) { <nl> - return YGValueIsUndefined ( b ) ; <nl> + if ( YGFloatIsUndefined ( a ) ) { <nl> + return YGFloatIsUndefined ( b ) ; <nl> } <nl> - return fabs ( a - b ) < 0 . 0001 ; <nl> + return fabs ( a - b ) < 0 . 0001f ; <nl> } <nl> <nl> static void YGIndent ( const uint32_t n ) { <nl> static void YGIndent ( const uint32_t n ) { <nl> } <nl> } <nl> <nl> - static void YGPrintNumberIfNotZero ( const char * str , const float number ) { <nl> - if ( ! YGFloatsEqual ( number , 0 ) ) { <nl> - YGLog ( YGLogLevelDebug , " % s : % g , " , str , number ) ; <nl> + static void YGPrintNumberIfNotZero ( const char * str , const YGValue * const number ) { <nl> + if ( ! YGFloatsEqual ( number - > value , 0 ) ) { <nl> + YGLog ( YGLogLevelDebug , <nl> + " % s : % g % s , " , <nl> + str , <nl> + number - > value , <nl> + number - > unit = = YGUnitPixel ? " px " : " % " ) ; <nl> } <nl> } <nl> <nl> - static void YGPrintNumberIfNotUndefined ( const char * str , const float number ) { <nl> - if ( ! YGValueIsUndefined ( number ) ) { <nl> + static void YGPrintNumberIfNotUndefinedf ( const char * str , const float number ) { <nl> + if ( ! YGFloatIsUndefined ( number ) ) { <nl> YGLog ( YGLogLevelDebug , " % s : % g , " , str , number ) ; <nl> } <nl> } <nl> <nl> - static bool YGFourFloatsEqual ( const float four [ 4 ] ) { <nl> - return YGFloatsEqual ( four [ 0 ] , four [ 1 ] ) & & YGFloatsEqual ( four [ 0 ] , four [ 2 ] ) & & <nl> - YGFloatsEqual ( four [ 0 ] , four [ 3 ] ) ; <nl> + static void YGPrintNumberIfNotUndefined ( const char * str , const YGValue * const number ) { <nl> + if ( number - > unit ! = YGUnitUndefined ) { <nl> + YGLog ( YGLogLevelDebug , <nl> + " % s : % g % s , " , <nl> + str , <nl> + number - > value , <nl> + number - > unit = = YGUnitPixel ? " px " : " % " ) ; <nl> + } <nl> + } <nl> + <nl> + static bool YGFourValuesEqual ( const YGValue four [ 4 ] ) { <nl> + return YGValueEqual ( four [ 0 ] , four [ 1 ] ) & & YGValueEqual ( four [ 0 ] , four [ 2 ] ) & & <nl> + YGValueEqual ( four [ 0 ] , four [ 3 ] ) ; <nl> } <nl> <nl> static void YGNodePrintInternal ( const YGNodeRef node , <nl> static void YGNodePrintInternal ( const YGNodeRef node , <nl> YGLog ( YGLogLevelDebug , " alignSelf : ' stretch ' , " ) ; <nl> } <nl> <nl> - YGPrintNumberIfNotUndefined ( " flexGrow " , YGNodeStyleGetFlexGrow ( node ) ) ; <nl> - YGPrintNumberIfNotUndefined ( " flexShrink " , YGNodeStyleGetFlexShrink ( node ) ) ; <nl> - YGPrintNumberIfNotUndefined ( " flexBasis " , YGNodeStyleGetFlexBasis ( node ) ) ; <nl> + YGPrintNumberIfNotUndefinedf ( " flexGrow " , YGNodeStyleGetFlexGrow ( node ) ) ; <nl> + YGPrintNumberIfNotUndefinedf ( " flexShrink " , YGNodeStyleGetFlexShrink ( node ) ) ; <nl> + YGPrintNumberIfNotUndefined ( " flexBasis " , YGNodeStyleGetFlexBasisPtr ( node ) ) ; <nl> <nl> if ( node - > style . overflow = = YGOverflowHidden ) { <nl> YGLog ( YGLogLevelDebug , " overflow : ' hidden ' , " ) ; <nl> static void YGNodePrintInternal ( const YGNodeRef node , <nl> YGLog ( YGLogLevelDebug , " overflow : ' scroll ' , " ) ; <nl> } <nl> <nl> - if ( YGFourFloatsEqual ( node - > style . margin ) ) { <nl> - YGPrintNumberIfNotZero ( " margin " , YGComputedEdgeValue ( node - > style . margin , YGEdgeLeft , 0 ) ) ; <nl> + if ( YGFourValuesEqual ( node - > style . margin ) ) { <nl> + YGPrintNumberIfNotZero ( " margin " , <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeLeft , & YGValueZero ) ) ; <nl> } else { <nl> - YGPrintNumberIfNotZero ( " marginLeft " , YGComputedEdgeValue ( node - > style . margin , YGEdgeLeft , 0 ) ) ; <nl> + YGPrintNumberIfNotZero ( " marginLeft " , <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeLeft , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " marginRight " , <nl> - YGComputedEdgeValue ( node - > style . margin , YGEdgeRight , 0 ) ) ; <nl> - YGPrintNumberIfNotZero ( " marginTop " , YGComputedEdgeValue ( node - > style . margin , YGEdgeTop , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeRight , & YGValueZero ) ) ; <nl> + YGPrintNumberIfNotZero ( " marginTop " , <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeTop , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " marginBottom " , <nl> - YGComputedEdgeValue ( node - > style . margin , YGEdgeBottom , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeBottom , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " marginStart " , <nl> - YGComputedEdgeValue ( node - > style . margin , YGEdgeStart , 0 ) ) ; <nl> - YGPrintNumberIfNotZero ( " marginEnd " , YGComputedEdgeValue ( node - > style . margin , YGEdgeEnd , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeStart , & YGValueZero ) ) ; <nl> + YGPrintNumberIfNotZero ( " marginEnd " , <nl> + YGComputedEdgeValue ( node - > style . margin , YGEdgeEnd , & YGValueZero ) ) ; <nl> } <nl> <nl> - if ( YGFourFloatsEqual ( node - > style . padding ) ) { <nl> - YGPrintNumberIfNotZero ( " padding " , YGComputedEdgeValue ( node - > style . padding , YGEdgeLeft , 0 ) ) ; <nl> + if ( YGFourValuesEqual ( node - > style . padding ) ) { <nl> + YGPrintNumberIfNotZero ( " padding " , <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeLeft , & YGValueZero ) ) ; <nl> } else { <nl> YGPrintNumberIfNotZero ( " paddingLeft " , <nl> - YGComputedEdgeValue ( node - > style . padding , YGEdgeLeft , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeLeft , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " paddingRight " , <nl> - YGComputedEdgeValue ( node - > style . padding , YGEdgeRight , 0 ) ) ; <nl> - YGPrintNumberIfNotZero ( " paddingTop " , YGComputedEdgeValue ( node - > style . padding , YGEdgeTop , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeRight , & YGValueZero ) ) ; <nl> + YGPrintNumberIfNotZero ( " paddingTop " , <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeTop , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " paddingBottom " , <nl> - YGComputedEdgeValue ( node - > style . padding , YGEdgeBottom , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeBottom , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " paddingStart " , <nl> - YGComputedEdgeValue ( node - > style . padding , YGEdgeStart , 0 ) ) ; <nl> - YGPrintNumberIfNotZero ( " paddingEnd " , YGComputedEdgeValue ( node - > style . padding , YGEdgeEnd , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeStart , & YGValueZero ) ) ; <nl> + YGPrintNumberIfNotZero ( " paddingEnd " , <nl> + YGComputedEdgeValue ( node - > style . padding , YGEdgeEnd , & YGValueZero ) ) ; <nl> } <nl> <nl> - if ( YGFourFloatsEqual ( node - > style . border ) ) { <nl> - YGPrintNumberIfNotZero ( " borderWidth " , YGComputedEdgeValue ( node - > style . border , YGEdgeLeft , 0 ) ) ; <nl> + if ( YGFourValuesEqual ( node - > style . border ) ) { <nl> + YGPrintNumberIfNotZero ( " borderWidth " , <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeLeft , & YGValueZero ) ) ; <nl> } else { <nl> YGPrintNumberIfNotZero ( " borderLeftWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeLeft , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeLeft , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " borderRightWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeRight , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeRight , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " borderTopWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeTop , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeTop , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " borderBottomWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeBottom , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeBottom , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " borderStartWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeStart , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeStart , & YGValueZero ) ) ; <nl> YGPrintNumberIfNotZero ( " borderEndWidth " , <nl> - YGComputedEdgeValue ( node - > style . border , YGEdgeEnd , 0 ) ) ; <nl> + YGComputedEdgeValue ( node - > style . border , YGEdgeEnd , & YGValueZero ) ) ; <nl> } <nl> <nl> - YGPrintNumberIfNotUndefined ( " width " , node - > style . dimensions [ YGDimensionWidth ] ) ; <nl> - YGPrintNumberIfNotUndefined ( " height " , node - > style . dimensions [ YGDimensionHeight ] ) ; <nl> - YGPrintNumberIfNotUndefined ( " maxWidth " , node - > style . maxDimensions [ YGDimensionWidth ] ) ; <nl> - YGPrintNumberIfNotUndefined ( " maxHeight " , node - > style . maxDimensions [ YGDimensionHeight ] ) ; <nl> - YGPrintNumberIfNotUndefined ( " minWidth " , node - > style . minDimensions [ YGDimensionWidth ] ) ; <nl> - YGPrintNumberIfNotUndefined ( " minHeight " , node - > style . minDimensions [ YGDimensionHeight ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " width " , & node - > style . dimensions [ YGDimensionWidth ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " height " , & node - > style . dimensions [ YGDimensionHeight ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " maxWidth " , & node - > style . maxDimensions [ YGDimensionWidth ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " maxHeight " , & node - > style . maxDimensions [ YGDimensionHeight ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " minWidth " , & node - > style . minDimensions [ YGDimensionWidth ] ) ; <nl> + YGPrintNumberIfNotUndefined ( " minHeight " , & node - > style . minDimensions [ YGDimensionHeight ] ) ; <nl> <nl> if ( node - > style . positionType = = YGPositionTypeAbsolute ) { <nl> YGLog ( YGLogLevelDebug , " position : ' absolute ' , " ) ; <nl> } <nl> <nl> - YGPrintNumberIfNotUndefined ( " left " , <nl> - YGComputedEdgeValue ( node - > style . position , YGEdgeLeft , YGUndefined ) ) ; <nl> YGPrintNumberIfNotUndefined ( <nl> - " right " , YGComputedEdgeValue ( node - > style . position , YGEdgeRight , YGUndefined ) ) ; <nl> - YGPrintNumberIfNotUndefined ( " top " , <nl> - YGComputedEdgeValue ( node - > style . position , YGEdgeTop , YGUndefined ) ) ; <nl> + " left " , YGComputedEdgeValue ( node - > style . position , YGEdgeLeft , & YGValueUndefined ) ) ; <nl> + YGPrintNumberIfNotUndefined ( <nl> + " right " , YGComputedEdgeValue ( node - > style . position , YGEdgeRight , & YGValueUndefined ) ) ; <nl> + YGPrintNumberIfNotUndefined ( <nl> + " top " , YGComputedEdgeValue ( node - > style . position , YGEdgeTop , & YGValueUndefined ) ) ; <nl> YGPrintNumberIfNotUndefined ( <nl> - " bottom " , YGComputedEdgeValue ( node - > style . position , YGEdgeBottom , YGUndefined ) ) ; <nl> + " bottom " , YGComputedEdgeValue ( node - > style . position , YGEdgeBottom , & YGValueUndefined ) ) ; <nl> } <nl> <nl> const uint32_t childCount = YGNodeListCount ( node - > children ) ; <nl> static inline bool YGFlexDirectionIsColumn ( const YGFlexDirection flexDirection ) <nl> return flexDirection = = YGFlexDirectionColumn | | flexDirection = = YGFlexDirectionColumnReverse ; <nl> } <nl> <nl> - static inline float YGNodeLeadingMargin ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . margin [ YGEdgeStart ] ) ) { <nl> - return node - > style . margin [ YGEdgeStart ] ; <nl> + static inline float YGNodeLeadingMargin ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . margin [ YGEdgeStart ] . unit ! = YGUnitUndefined ) { <nl> + return YGValueResolve ( & node - > style . margin [ YGEdgeStart ] , widthSize ) ; <nl> } <nl> <nl> - return YGComputedEdgeValue ( node - > style . margin , leading [ axis ] , 0 ) ; <nl> + return YGValueResolve ( YGComputedEdgeValue ( node - > style . margin , leading [ axis ] , & YGValueZero ) , <nl> + widthSize ) ; <nl> } <nl> <nl> - static float YGNodeTrailingMargin ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . margin [ YGEdgeEnd ] ) ) { <nl> - return node - > style . margin [ YGEdgeEnd ] ; <nl> + static float YGNodeTrailingMargin ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . margin [ YGEdgeEnd ] . unit ! = YGUnitUndefined ) { <nl> + return YGValueResolve ( & node - > style . margin [ YGEdgeEnd ] , widthSize ) ; <nl> } <nl> <nl> - return YGComputedEdgeValue ( node - > style . margin , trailing [ axis ] , 0 ) ; <nl> + return YGValueResolve ( YGComputedEdgeValue ( node - > style . margin , trailing [ axis ] , & YGValueZero ) , <nl> + widthSize ) ; <nl> } <nl> <nl> - static float YGNodeLeadingPadding ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . padding [ YGEdgeStart ] ) & & <nl> - node - > style . padding [ YGEdgeStart ] > = 0 ) { <nl> - return node - > style . padding [ YGEdgeStart ] ; <nl> + static float YGNodeLeadingPadding ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . padding [ YGEdgeStart ] . unit ! = YGUnitUndefined & & <nl> + YGValueResolve ( & node - > style . padding [ YGEdgeStart ] , widthSize ) > = 0 . 0f ) { <nl> + return YGValueResolve ( & node - > style . padding [ YGEdgeStart ] , widthSize ) ; <nl> } <nl> <nl> - return fmaxf ( YGComputedEdgeValue ( node - > style . padding , leading [ axis ] , 0 ) , 0 ) ; <nl> + return fmaxf ( YGValueResolve ( YGComputedEdgeValue ( node - > style . padding , leading [ axis ] , & YGValueZero ) , <nl> + widthSize ) , <nl> + 0 . 0f ) ; <nl> } <nl> <nl> - static float YGNodeTrailingPadding ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . padding [ YGEdgeEnd ] ) & & <nl> - node - > style . padding [ YGEdgeEnd ] > = 0 ) { <nl> - return node - > style . padding [ YGEdgeEnd ] ; <nl> + static float YGNodeTrailingPadding ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . padding [ YGEdgeEnd ] . unit ! = YGUnitUndefined & & <nl> + YGValueResolve ( & node - > style . padding [ YGEdgeEnd ] , widthSize ) > = 0 . 0f ) { <nl> + return YGValueResolve ( & node - > style . padding [ YGEdgeEnd ] , widthSize ) ; <nl> } <nl> <nl> - return fmaxf ( YGComputedEdgeValue ( node - > style . padding , trailing [ axis ] , 0 ) , 0 ) ; <nl> + return fmaxf ( YGValueResolve ( YGComputedEdgeValue ( node - > style . padding , trailing [ axis ] , & YGValueZero ) , <nl> + widthSize ) , <nl> + 0 . 0f ) ; <nl> } <nl> <nl> static float YGNodeLeadingBorder ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . border [ YGEdgeStart ] ) & & <nl> - node - > style . border [ YGEdgeStart ] > = 0 ) { <nl> - return node - > style . border [ YGEdgeStart ] ; <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . border [ YGEdgeStart ] . unit ! = YGUnitUndefined & & <nl> + node - > style . border [ YGEdgeStart ] . value > = 0 . 0f ) { <nl> + return node - > style . border [ YGEdgeStart ] . value ; <nl> } <nl> <nl> - return fmaxf ( YGComputedEdgeValue ( node - > style . border , leading [ axis ] , 0 ) , 0 ) ; <nl> + return fmaxf ( YGComputedEdgeValue ( node - > style . border , leading [ axis ] , & YGValueZero ) - > value , 0 . 0f ) ; <nl> } <nl> <nl> static float YGNodeTrailingBorder ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - if ( YGFlexDirectionIsRow ( axis ) & & ! YGValueIsUndefined ( node - > style . border [ YGEdgeEnd ] ) & & <nl> - node - > style . border [ YGEdgeEnd ] > = 0 ) { <nl> - return node - > style . border [ YGEdgeEnd ] ; <nl> + if ( YGFlexDirectionIsRow ( axis ) & & node - > style . border [ YGEdgeEnd ] . unit ! = YGUnitUndefined & & <nl> + node - > style . border [ YGEdgeEnd ] . value > = 0 . 0f ) { <nl> + return node - > style . border [ YGEdgeEnd ] . value ; <nl> } <nl> <nl> - return fmaxf ( YGComputedEdgeValue ( node - > style . border , trailing [ axis ] , 0 ) , 0 ) ; <nl> + return fmaxf ( YGComputedEdgeValue ( node - > style . border , trailing [ axis ] , & YGValueZero ) - > value , 0 . 0f ) ; <nl> } <nl> <nl> static inline float YGNodeLeadingPaddingAndBorder ( const YGNodeRef node , <nl> - const YGFlexDirection axis ) { <nl> - return YGNodeLeadingPadding ( node , axis ) + YGNodeLeadingBorder ( node , axis ) ; <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + return YGNodeLeadingPadding ( node , axis , widthSize ) + YGNodeLeadingBorder ( node , axis ) ; <nl> } <nl> <nl> static inline float YGNodeTrailingPaddingAndBorder ( const YGNodeRef node , <nl> - const YGFlexDirection axis ) { <nl> - return YGNodeTrailingPadding ( node , axis ) + YGNodeTrailingBorder ( node , axis ) ; <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + return YGNodeTrailingPadding ( node , axis , widthSize ) + YGNodeTrailingBorder ( node , axis ) ; <nl> } <nl> <nl> - static inline float YGNodeMarginForAxis ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - return YGNodeLeadingMargin ( node , axis ) + YGNodeTrailingMargin ( node , axis ) ; <nl> + static inline float YGNodeMarginForAxis ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + return YGNodeLeadingMargin ( node , axis , widthSize ) + YGNodeTrailingMargin ( node , axis , widthSize ) ; <nl> } <nl> <nl> static inline float YGNodePaddingAndBorderForAxis ( const YGNodeRef node , <nl> - const YGFlexDirection axis ) { <nl> - return YGNodeLeadingPaddingAndBorder ( node , axis ) + YGNodeTrailingPaddingAndBorder ( node , axis ) ; <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + return YGNodeLeadingPaddingAndBorder ( node , axis , widthSize ) + <nl> + YGNodeTrailingPaddingAndBorder ( node , axis , widthSize ) ; <nl> } <nl> <nl> static inline YGAlign YGNodeAlignItem ( const YGNodeRef node , const YGNodeRef child ) { <nl> static inline bool YGNodeIsFlex ( const YGNodeRef node ) { <nl> ( YGNodeStyleGetFlexGrow ( node ) ! = 0 | | YGNodeStyleGetFlexShrink ( node ) ! = 0 ) ) ; <nl> } <nl> <nl> - static inline float YGNodeDimWithMargin ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - return node - > layout . measuredDimensions [ dim [ axis ] ] + YGNodeLeadingMargin ( node , axis ) + <nl> - YGNodeTrailingMargin ( node , axis ) ; <nl> + static inline float YGNodeDimWithMargin ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float widthSize ) { <nl> + return node - > layout . measuredDimensions [ dim [ axis ] ] + YGNodeLeadingMargin ( node , axis , widthSize ) + <nl> + YGNodeTrailingMargin ( node , axis , widthSize ) ; <nl> } <nl> <nl> static inline bool YGNodeIsStyleDimDefined ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - const float value = node - > style . dimensions [ dim [ axis ] ] ; <nl> - return ! YGValueIsUndefined ( value ) & & value > = 0 . 0 ; <nl> + return node - > style . dimensions [ dim [ axis ] ] . unit ! = YGUnitUndefined & & <nl> + node - > style . dimensions [ dim [ axis ] ] . value > = 0 . 0f ; <nl> } <nl> <nl> static inline bool YGNodeIsLayoutDimDefined ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> const float value = node - > layout . measuredDimensions [ dim [ axis ] ] ; <nl> - return ! YGValueIsUndefined ( value ) & & value > = 0 . 0 ; <nl> + return ! YGFloatIsUndefined ( value ) & & value > = 0 . 0f ; <nl> } <nl> <nl> static inline bool YGNodeIsLeadingPosDefined ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> return ( YGFlexDirectionIsRow ( axis ) & & <nl> - ! YGValueIsUndefined ( <nl> - YGComputedEdgeValue ( node - > style . position , YGEdgeStart , YGUndefined ) ) ) | | <nl> - ! YGValueIsUndefined ( YGComputedEdgeValue ( node - > style . position , leading [ axis ] , YGUndefined ) ) ; <nl> + YGComputedEdgeValue ( node - > style . position , YGEdgeStart , & YGValueUndefined ) - > unit ! = <nl> + YGUnitUndefined ) | | <nl> + YGComputedEdgeValue ( node - > style . position , leading [ axis ] , & YGValueUndefined ) - > unit ! = <nl> + YGUnitUndefined ; <nl> } <nl> <nl> static inline bool YGNodeIsTrailingPosDefined ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> return ( YGFlexDirectionIsRow ( axis ) & & <nl> - ! YGValueIsUndefined ( YGComputedEdgeValue ( node - > style . position , YGEdgeEnd , YGUndefined ) ) ) | | <nl> - ! YGValueIsUndefined ( <nl> - YGComputedEdgeValue ( node - > style . position , trailing [ axis ] , YGUndefined ) ) ; <nl> + YGComputedEdgeValue ( node - > style . position , YGEdgeEnd , & YGValueUndefined ) - > unit ! = <nl> + YGUnitUndefined ) | | <nl> + YGComputedEdgeValue ( node - > style . position , trailing [ axis ] , & YGValueUndefined ) - > unit ! = <nl> + YGUnitUndefined ; <nl> } <nl> <nl> - static float YGNodeLeadingPosition ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> + static float YGNodeLeadingPosition ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float axisSize ) { <nl> if ( YGFlexDirectionIsRow ( axis ) ) { <nl> - const float leadingPosition = <nl> - YGComputedEdgeValue ( node - > style . position , YGEdgeStart , YGUndefined ) ; <nl> - if ( ! YGValueIsUndefined ( leadingPosition ) ) { <nl> - return leadingPosition ; <nl> + const YGValue * leadingPosition = <nl> + YGComputedEdgeValue ( node - > style . position , YGEdgeStart , & YGValueUndefined ) ; <nl> + if ( leadingPosition - > unit ! = YGUnitUndefined ) { <nl> + return YGValueResolve ( leadingPosition , axisSize ) ; <nl> } <nl> } <nl> <nl> - const float leadingPosition = <nl> - YGComputedEdgeValue ( node - > style . position , leading [ axis ] , YGUndefined ) ; <nl> + const YGValue * leadingPosition = <nl> + YGComputedEdgeValue ( node - > style . position , leading [ axis ] , & YGValueUndefined ) ; <nl> <nl> - return YGValueIsUndefined ( leadingPosition ) ? 0 : leadingPosition ; <nl> + return leadingPosition - > unit = = YGUnitUndefined ? 0 . 0f <nl> + : YGValueResolve ( leadingPosition , axisSize ) ; <nl> } <nl> <nl> - static float YGNodeTrailingPosition ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> + static float YGNodeTrailingPosition ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float axisSize ) { <nl> if ( YGFlexDirectionIsRow ( axis ) ) { <nl> - const float trailingPosition = <nl> - YGComputedEdgeValue ( node - > style . position , YGEdgeEnd , YGUndefined ) ; <nl> - if ( ! YGValueIsUndefined ( trailingPosition ) ) { <nl> - return trailingPosition ; <nl> + const YGValue * trailingPosition = <nl> + YGComputedEdgeValue ( node - > style . position , YGEdgeEnd , & YGValueUndefined ) ; <nl> + if ( trailingPosition - > unit ! = YGUnitUndefined ) { <nl> + return YGValueResolve ( trailingPosition , axisSize ) ; <nl> } <nl> } <nl> <nl> - const float trailingPosition = <nl> - YGComputedEdgeValue ( node - > style . position , trailing [ axis ] , YGUndefined ) ; <nl> + const YGValue * trailingPosition = <nl> + YGComputedEdgeValue ( node - > style . position , trailing [ axis ] , & YGValueUndefined ) ; <nl> <nl> - return YGValueIsUndefined ( trailingPosition ) ? 0 : trailingPosition ; <nl> + return trailingPosition - > unit = = YGUnitUndefined ? 0 . 0f <nl> + : YGValueResolve ( trailingPosition , axisSize ) ; <nl> } <nl> <nl> static float YGNodeBoundAxisWithinMinAndMax ( const YGNodeRef node , <nl> const YGFlexDirection axis , <nl> - const float value ) { <nl> + const float value , <nl> + const float axisSize ) { <nl> float min = YGUndefined ; <nl> float max = YGUndefined ; <nl> <nl> if ( YGFlexDirectionIsColumn ( axis ) ) { <nl> - min = node - > style . minDimensions [ YGDimensionHeight ] ; <nl> - max = node - > style . maxDimensions [ YGDimensionHeight ] ; <nl> + min = YGValueResolve ( & node - > style . minDimensions [ YGDimensionHeight ] , axisSize ) ; <nl> + max = YGValueResolve ( & node - > style . maxDimensions [ YGDimensionHeight ] , axisSize ) ; <nl> } else if ( YGFlexDirectionIsRow ( axis ) ) { <nl> - min = node - > style . minDimensions [ YGDimensionWidth ] ; <nl> - max = node - > style . maxDimensions [ YGDimensionWidth ] ; <nl> + min = YGValueResolve ( & node - > style . minDimensions [ YGDimensionWidth ] , axisSize ) ; <nl> + max = YGValueResolve ( & node - > style . maxDimensions [ YGDimensionWidth ] , axisSize ) ; <nl> } <nl> <nl> float boundValue = value ; <nl> <nl> - if ( ! YGValueIsUndefined ( max ) & & max > = 0 . 0 & & boundValue > max ) { <nl> + if ( ! YGFloatIsUndefined ( max ) & & max > = 0 . 0f & & boundValue > max ) { <nl> boundValue = max ; <nl> } <nl> <nl> - if ( ! YGValueIsUndefined ( min ) & & min > = 0 . 0 & & boundValue < min ) { <nl> + if ( ! YGFloatIsUndefined ( min ) & & min > = 0 . 0f & & boundValue < min ) { <nl> boundValue = min ; <nl> } <nl> <nl> static float YGNodeBoundAxisWithinMinAndMax ( const YGNodeRef node , <nl> / / padding and border amount . <nl> static inline float YGNodeBoundAxis ( const YGNodeRef node , <nl> const YGFlexDirection axis , <nl> - const float value ) { <nl> - return fmaxf ( YGNodeBoundAxisWithinMinAndMax ( node , axis , value ) , <nl> - YGNodePaddingAndBorderForAxis ( node , axis ) ) ; <nl> + const float value , <nl> + const float axisSize , <nl> + const float widthSize ) { <nl> + return fmaxf ( YGNodeBoundAxisWithinMinAndMax ( node , axis , value , axisSize ) , <nl> + YGNodePaddingAndBorderForAxis ( node , axis , widthSize ) ) ; <nl> } <nl> <nl> static void YGNodeSetChildTrailingPosition ( const YGNodeRef node , <nl> static void YGNodeSetChildTrailingPosition ( const YGNodeRef node , <nl> <nl> / / If both left and right are defined , then use left . Otherwise return <nl> / / + left or - right depending on which is defined . <nl> - static float YGNodeRelativePosition ( const YGNodeRef node , const YGFlexDirection axis ) { <nl> - return YGNodeIsLeadingPosDefined ( node , axis ) ? YGNodeLeadingPosition ( node , axis ) <nl> - : - YGNodeTrailingPosition ( node , axis ) ; <nl> + static float YGNodeRelativePosition ( const YGNodeRef node , <nl> + const YGFlexDirection axis , <nl> + const float axisSize ) { <nl> + return YGNodeIsLeadingPosDefined ( node , axis ) ? YGNodeLeadingPosition ( node , axis , axisSize ) <nl> + : - YGNodeTrailingPosition ( node , axis , axisSize ) ; <nl> } <nl> <nl> static void YGConstrainMaxSizeForMode ( const float maxSize , YGMeasureMode * mode , float * size ) { <nl> switch ( * mode ) { <nl> case YGMeasureModeExactly : <nl> case YGMeasureModeAtMost : <nl> - * size = ( YGValueIsUndefined ( maxSize ) | | * size < maxSize ) ? * size : maxSize ; <nl> + * size = ( YGFloatIsUndefined ( maxSize ) | | * size < maxSize ) ? * size : maxSize ; <nl> break ; <nl> case YGMeasureModeUndefined : <nl> - if ( ! YGValueIsUndefined ( maxSize ) ) { <nl> + if ( ! YGFloatIsUndefined ( maxSize ) ) { <nl> * mode = YGMeasureModeAtMost ; <nl> * size = maxSize ; <nl> } <nl> static void YGConstrainMaxSizeForMode ( const float maxSize , YGMeasureMode * mode , <nl> } <nl> } <nl> <nl> - static void YGNodeSetPosition ( const YGNodeRef node , const YGDirection direction ) { <nl> + static void YGNodeSetPosition ( const YGNodeRef node , <nl> + const YGDirection direction , <nl> + const float mainSize , <nl> + const float crossSize , <nl> + const float parentWidth ) { <nl> const YGFlexDirection mainAxis = YGFlexDirectionResolve ( node - > style . flexDirection , direction ) ; <nl> const YGFlexDirection crossAxis = YGFlexDirectionCross ( mainAxis , direction ) ; <nl> - const float relativePositionMain = YGNodeRelativePosition ( node , mainAxis ) ; <nl> - const float relativePositionCross = YGNodeRelativePosition ( node , crossAxis ) ; <nl> + const float relativePositionMain = YGNodeRelativePosition ( node , mainAxis , mainSize ) ; <nl> + const float relativePositionCross = YGNodeRelativePosition ( node , crossAxis , crossSize ) ; <nl> <nl> node - > layout . position [ leading [ mainAxis ] ] = <nl> - YGNodeLeadingMargin ( node , mainAxis ) + relativePositionMain ; <nl> + YGNodeLeadingMargin ( node , mainAxis , parentWidth ) + relativePositionMain ; <nl> node - > layout . position [ trailing [ mainAxis ] ] = <nl> - YGNodeTrailingMargin ( node , mainAxis ) + relativePositionMain ; <nl> + YGNodeTrailingMargin ( node , mainAxis , parentWidth ) + relativePositionMain ; <nl> node - > layout . position [ leading [ crossAxis ] ] = <nl> - YGNodeLeadingMargin ( node , crossAxis ) + relativePositionCross ; <nl> + YGNodeLeadingMargin ( node , crossAxis , parentWidth ) + relativePositionCross ; <nl> node - > layout . position [ trailing [ crossAxis ] ] = <nl> - YGNodeTrailingMargin ( node , crossAxis ) + relativePositionCross ; <nl> + YGNodeTrailingMargin ( node , crossAxis , parentWidth ) + relativePositionCross ; <nl> } <nl> <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> const float width , <nl> const YGMeasureMode widthMode , <nl> const float height , <nl> + const float parentWidth , <nl> + const float parentHeight , <nl> const YGMeasureMode heightMode , <nl> const YGDirection direction ) { <nl> const YGFlexDirection mainAxis = YGFlexDirectionResolve ( node - > style . flexDirection , direction ) ; <nl> const bool isMainAxisRow = YGFlexDirectionIsRow ( mainAxis ) ; <nl> + const float mainAxisSize = isMainAxisRow ? width : height ; <nl> + const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight ; <nl> <nl> float childWidth ; <nl> float childHeight ; <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined ( child , YGFlexDirectionRow ) ; <nl> const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined ( child , YGFlexDirectionColumn ) ; <nl> <nl> - if ( ! YGValueIsUndefined ( YGNodeStyleGetFlexBasis ( child ) ) & & <nl> - ! YGValueIsUndefined ( isMainAxisRow ? width : height ) ) { <nl> - if ( YGValueIsUndefined ( child - > layout . computedFlexBasis ) | | <nl> + if ( YGNodeStyleGetFlexBasisPtr ( child ) - > unit ! = YGUnitUndefined & & <nl> + ! YGFloatIsUndefined ( mainAxisSize ) ) { <nl> + if ( YGFloatIsUndefined ( child - > layout . computedFlexBasis ) | | <nl> ( YGIsExperimentalFeatureEnabled ( YGExperimentalFeatureWebFlexBasis ) & & <nl> child - > layout . computedFlexBasisGeneration ! = gCurrentGenerationCount ) ) { <nl> child - > layout . computedFlexBasis = <nl> - fmaxf ( YGNodeStyleGetFlexBasis ( child ) , YGNodePaddingAndBorderForAxis ( child , mainAxis ) ) ; <nl> + fmaxf ( YGValueResolve ( YGNodeStyleGetFlexBasisPtr ( child ) , mainAxisParentSize ) , <nl> + YGNodePaddingAndBorderForAxis ( child , mainAxis , parentWidth ) ) ; <nl> } <nl> } else if ( isMainAxisRow & & isRowStyleDimDefined ) { <nl> / / The width is definite , so use that as the flex basis . <nl> child - > layout . computedFlexBasis = <nl> - fmaxf ( child - > style . dimensions [ YGDimensionWidth ] , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow ) ) ; <nl> + fmaxf ( YGValueResolve ( & child - > style . dimensions [ YGDimensionWidth ] , parentWidth ) , <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow , parentWidth ) ) ; <nl> } else if ( ! isMainAxisRow & & isColumnStyleDimDefined ) { <nl> / / The height is definite , so use that as the flex basis . <nl> child - > layout . computedFlexBasis = <nl> - fmaxf ( child - > style . dimensions [ YGDimensionHeight ] , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn ) ) ; <nl> + fmaxf ( YGValueResolve ( & child - > style . dimensions [ YGDimensionHeight ] , parentHeight ) , <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn , parentWidth ) ) ; <nl> } else { <nl> / / Compute the flex basis and hypothetical main size ( i . e . the clamped <nl> / / flex basis ) . <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> childHeightMeasureMode = YGMeasureModeUndefined ; <nl> <nl> if ( isRowStyleDimDefined ) { <nl> - childWidth = child - > style . dimensions [ YGDimensionWidth ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionRow ) ; <nl> + childWidth = YGValueResolve ( & child - > style . dimensions [ YGDimensionWidth ] , parentWidth ) + <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionRow , parentWidth ) ; <nl> childWidthMeasureMode = YGMeasureModeExactly ; <nl> } <nl> if ( isColumnStyleDimDefined ) { <nl> - childHeight = child - > style . dimensions [ YGDimensionHeight ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionColumn ) ; <nl> + childHeight = YGValueResolve ( & child - > style . dimensions [ YGDimensionHeight ] , parentHeight ) + <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionColumn , parentWidth ) ; <nl> childHeightMeasureMode = YGMeasureModeExactly ; <nl> } <nl> <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> / / but all major browsers appear to implement the following logic . <nl> if ( ( ! isMainAxisRow & & node - > style . overflow = = YGOverflowScroll ) | | <nl> node - > style . overflow ! = YGOverflowScroll ) { <nl> - if ( YGValueIsUndefined ( childWidth ) & & ! YGValueIsUndefined ( width ) ) { <nl> + if ( YGFloatIsUndefined ( childWidth ) & & ! YGFloatIsUndefined ( width ) ) { <nl> childWidth = width ; <nl> childWidthMeasureMode = YGMeasureModeAtMost ; <nl> } <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> <nl> if ( ( isMainAxisRow & & node - > style . overflow = = YGOverflowScroll ) | | <nl> node - > style . overflow ! = YGOverflowScroll ) { <nl> - if ( YGValueIsUndefined ( childHeight ) & & ! YGValueIsUndefined ( height ) ) { <nl> + if ( YGFloatIsUndefined ( childHeight ) & & ! YGFloatIsUndefined ( height ) ) { <nl> childHeight = height ; <nl> childHeightMeasureMode = YGMeasureModeAtMost ; <nl> } <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> / / If child has no defined size in the cross axis and is set to stretch , <nl> / / set the cross <nl> / / axis to be measured exactly with the available inner width <nl> - if ( ! isMainAxisRow & & ! YGValueIsUndefined ( width ) & & ! isRowStyleDimDefined & & <nl> + if ( ! isMainAxisRow & & ! YGFloatIsUndefined ( width ) & & ! isRowStyleDimDefined & & <nl> widthMode = = YGMeasureModeExactly & & YGNodeAlignItem ( node , child ) = = YGAlignStretch ) { <nl> childWidth = width ; <nl> childWidthMeasureMode = YGMeasureModeExactly ; <nl> } <nl> - if ( isMainAxisRow & & ! YGValueIsUndefined ( height ) & & ! isColumnStyleDimDefined & & <nl> + if ( isMainAxisRow & & ! YGFloatIsUndefined ( height ) & & ! isColumnStyleDimDefined & & <nl> heightMode = = YGMeasureModeExactly & & YGNodeAlignItem ( node , child ) = = YGAlignStretch ) { <nl> childHeight = height ; <nl> childHeightMeasureMode = YGMeasureModeExactly ; <nl> } <nl> <nl> - if ( ! YGValueIsUndefined ( child - > style . aspectRatio ) ) { <nl> + if ( ! YGFloatIsUndefined ( child - > style . aspectRatio ) ) { <nl> if ( ! isMainAxisRow & & childWidthMeasureMode = = YGMeasureModeExactly ) { <nl> child - > layout . computedFlexBasis = <nl> fmaxf ( childWidth / child - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn ) ) ; <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn , parentWidth ) ) ; <nl> return ; <nl> } else if ( isMainAxisRow & & childHeightMeasureMode = = YGMeasureModeExactly ) { <nl> child - > layout . computedFlexBasis = <nl> fmaxf ( childHeight * child - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow ) ) ; <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow , parentWidth ) ) ; <nl> return ; <nl> } <nl> } <nl> <nl> - YGConstrainMaxSizeForMode ( child - > style . maxDimensions [ YGDimensionWidth ] , <nl> + YGConstrainMaxSizeForMode ( YGValueResolve ( & child - > style . maxDimensions [ YGDimensionWidth ] , <nl> + parentWidth ) , <nl> & childWidthMeasureMode , <nl> & childWidth ) ; <nl> - YGConstrainMaxSizeForMode ( child - > style . maxDimensions [ YGDimensionHeight ] , <nl> + YGConstrainMaxSizeForMode ( YGValueResolve ( & child - > style . maxDimensions [ YGDimensionHeight ] , <nl> + parentHeight ) , <nl> & childHeightMeasureMode , <nl> & childHeight ) ; <nl> <nl> static void YGNodeComputeFlexBasisForChild ( const YGNodeRef node , <nl> direction , <nl> childWidthMeasureMode , <nl> childHeightMeasureMode , <nl> + parentWidth , <nl> + parentHeight , <nl> false , <nl> " measure " ) ; <nl> <nl> child - > layout . computedFlexBasis = <nl> fmaxf ( isMainAxisRow ? child - > layout . measuredDimensions [ YGDimensionWidth ] <nl> : child - > layout . measuredDimensions [ YGDimensionHeight ] , <nl> - YGNodePaddingAndBorderForAxis ( child , mainAxis ) ) ; <nl> + YGNodePaddingAndBorderForAxis ( child , mainAxis , parentWidth ) ) ; <nl> } <nl> <nl> child - > layout . computedFlexBasisGeneration = gCurrentGenerationCount ; <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> const YGNodeRef child , <nl> const float width , <nl> const YGMeasureMode widthMode , <nl> + const float height , <nl> const YGDirection direction ) { <nl> const YGFlexDirection mainAxis = YGFlexDirectionResolve ( node - > style . flexDirection , direction ) ; <nl> const YGFlexDirection crossAxis = YGFlexDirectionCross ( mainAxis , direction ) ; <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined ; <nl> <nl> if ( YGNodeIsStyleDimDefined ( child , YGFlexDirectionRow ) ) { <nl> - childWidth = <nl> - child - > style . dimensions [ YGDimensionWidth ] + YGNodeMarginForAxis ( child , YGFlexDirectionRow ) ; <nl> + childWidth = YGValueResolve ( & child - > style . dimensions [ YGDimensionWidth ] , width ) + <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionRow , width ) ; <nl> } else { <nl> / / If the child doesn ' t have a specified width , compute the width based <nl> / / on the left / right <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> childWidth = node - > layout . measuredDimensions [ YGDimensionWidth ] - <nl> ( YGNodeLeadingBorder ( node , YGFlexDirectionRow ) + <nl> YGNodeTrailingBorder ( node , YGFlexDirectionRow ) ) - <nl> - ( YGNodeLeadingPosition ( child , YGFlexDirectionRow ) + <nl> - YGNodeTrailingPosition ( child , YGFlexDirectionRow ) ) ; <nl> - childWidth = YGNodeBoundAxis ( child , YGFlexDirectionRow , childWidth ) ; <nl> + ( YGNodeLeadingPosition ( child , YGFlexDirectionRow , width ) + <nl> + YGNodeTrailingPosition ( child , YGFlexDirectionRow , width ) ) ; <nl> + childWidth = YGNodeBoundAxis ( child , YGFlexDirectionRow , childWidth , width , width ) ; <nl> } <nl> } <nl> <nl> if ( YGNodeIsStyleDimDefined ( child , YGFlexDirectionColumn ) ) { <nl> - childHeight = child - > style . dimensions [ YGDimensionHeight ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionColumn ) ; <nl> + childHeight = YGValueResolve ( & child - > style . dimensions [ YGDimensionHeight ] , height ) + <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionColumn , width ) ; <nl> } else { <nl> / / If the child doesn ' t have a specified height , compute the height <nl> / / based on the top / bottom <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> childHeight = node - > layout . measuredDimensions [ YGDimensionHeight ] - <nl> ( YGNodeLeadingBorder ( node , YGFlexDirectionColumn ) + <nl> YGNodeTrailingBorder ( node , YGFlexDirectionColumn ) ) - <nl> - ( YGNodeLeadingPosition ( child , YGFlexDirectionColumn ) + <nl> - YGNodeTrailingPosition ( child , YGFlexDirectionColumn ) ) ; <nl> - childHeight = YGNodeBoundAxis ( child , YGFlexDirectionColumn , childHeight ) ; <nl> + ( YGNodeLeadingPosition ( child , YGFlexDirectionColumn , height ) + <nl> + YGNodeTrailingPosition ( child , YGFlexDirectionColumn , height ) ) ; <nl> + childHeight = YGNodeBoundAxis ( child , YGFlexDirectionColumn , childHeight , height , width ) ; <nl> } <nl> } <nl> <nl> / / Exactly one dimension needs to be defined for us to be able to do aspect ratio <nl> / / calculation . One dimension being the anchor and the other being flexible . <nl> - if ( YGValueIsUndefined ( childWidth ) ^ YGValueIsUndefined ( childHeight ) ) { <nl> - if ( ! YGValueIsUndefined ( child - > style . aspectRatio ) ) { <nl> - if ( YGValueIsUndefined ( childWidth ) ) { <nl> + if ( YGFloatIsUndefined ( childWidth ) ^ YGFloatIsUndefined ( childHeight ) ) { <nl> + if ( ! YGFloatIsUndefined ( child - > style . aspectRatio ) ) { <nl> + if ( YGFloatIsUndefined ( childWidth ) ) { <nl> childWidth = fmaxf ( childHeight * child - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn ) ) ; <nl> - } else if ( YGValueIsUndefined ( childHeight ) ) { <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionColumn , width ) ) ; <nl> + } else if ( YGFloatIsUndefined ( childHeight ) ) { <nl> childHeight = fmaxf ( childWidth / child - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow ) ) ; <nl> + YGNodePaddingAndBorderForAxis ( child , YGFlexDirectionRow , width ) ) ; <nl> } <nl> } <nl> } <nl> <nl> / / If we ' re still missing one or the other dimension , measure the content . <nl> - if ( YGValueIsUndefined ( childWidth ) | | YGValueIsUndefined ( childHeight ) ) { <nl> + if ( YGFloatIsUndefined ( childWidth ) | | YGFloatIsUndefined ( childHeight ) ) { <nl> childWidthMeasureMode = <nl> - YGValueIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> + YGFloatIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> childHeightMeasureMode = <nl> - YGValueIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> + YGFloatIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> <nl> / / According to the spec , if the main size is not definite and the <nl> / / child ' s inline axis is parallel to the main axis ( i . e . it ' s <nl> / / horizontal ) , the child should be sized using " UNDEFINED " in <nl> / / the main size . Otherwise use " AT_MOST " in the cross axis . <nl> - if ( ! isMainAxisRow & & YGValueIsUndefined ( childWidth ) & & widthMode ! = YGMeasureModeUndefined ) { <nl> + if ( ! isMainAxisRow & & YGFloatIsUndefined ( childWidth ) & & widthMode ! = YGMeasureModeUndefined ) { <nl> childWidth = width ; <nl> childWidthMeasureMode = YGMeasureModeAtMost ; <nl> } <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> direction , <nl> childWidthMeasureMode , <nl> childHeightMeasureMode , <nl> + childWidth , <nl> + childHeight , <nl> false , <nl> " abs - measure " ) ; <nl> childWidth = child - > layout . measuredDimensions [ YGDimensionWidth ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionRow ) ; <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionRow , width ) ; <nl> childHeight = child - > layout . measuredDimensions [ YGDimensionHeight ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionColumn ) ; <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionColumn , width ) ; <nl> } <nl> <nl> YGLayoutNodeInternal ( child , <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> direction , <nl> YGMeasureModeExactly , <nl> YGMeasureModeExactly , <nl> + childWidth , <nl> + childHeight , <nl> true , <nl> " abs - layout " ) ; <nl> <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> child - > layout . position [ leading [ mainAxis ] ] = node - > layout . measuredDimensions [ dim [ mainAxis ] ] - <nl> child - > layout . measuredDimensions [ dim [ mainAxis ] ] - <nl> YGNodeTrailingBorder ( node , mainAxis ) - <nl> - YGNodeTrailingPosition ( child , mainAxis ) ; <nl> + YGNodeTrailingPosition ( child , mainAxis , width ) ; <nl> } <nl> <nl> if ( YGNodeIsTrailingPosDefined ( child , crossAxis ) & & <nl> static void YGNodeAbsoluteLayoutChild ( const YGNodeRef node , <nl> child - > layout . position [ leading [ crossAxis ] ] = node - > layout . measuredDimensions [ dim [ crossAxis ] ] - <nl> child - > layout . measuredDimensions [ dim [ crossAxis ] ] - <nl> YGNodeTrailingBorder ( node , crossAxis ) - <nl> - YGNodeTrailingPosition ( child , crossAxis ) ; <nl> + YGNodeTrailingPosition ( child , crossAxis , width ) ; <nl> } <nl> } <nl> <nl> static void YGNodeWithMeasureFuncSetMeasuredDimensions ( const YGNodeRef node , <nl> const YGMeasureMode heightMeasureMode ) { <nl> YG_ASSERT ( node - > measure , " Expected node to have custom measure function " ) ; <nl> <nl> - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionRow ) ; <nl> + const float paddingAndBorderAxisRow = <nl> + YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionRow , availableWidth ) ; <nl> const float paddingAndBorderAxisColumn = <nl> - YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionColumn ) ; <nl> - const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> - const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> + YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionColumn , availableWidth ) ; <nl> + const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow , availableWidth ) ; <nl> + const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn , availableWidth ) ; <nl> <nl> const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow ; <nl> const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn ; <nl> <nl> if ( widthMeasureMode = = YGMeasureModeExactly & & heightMeasureMode = = YGMeasureModeExactly ) { <nl> / / Don ' t bother sizing the text if both dimensions are already defined . <nl> - node - > layout . measuredDimensions [ YGDimensionWidth ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionRow , availableWidth - marginAxisRow ) ; <nl> + node - > layout . measuredDimensions [ YGDimensionWidth ] = YGNodeBoundAxis ( <nl> + node , YGFlexDirectionRow , availableWidth - marginAxisRow , availableWidth , availableWidth ) ; <nl> node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionColumn , availableHeight - marginAxisColumn ) ; <nl> - } else if ( innerWidth < = 0 | | innerHeight < = 0 ) { <nl> + YGNodeBoundAxis ( node , <nl> + YGFlexDirectionColumn , <nl> + availableHeight - marginAxisColumn , <nl> + availableHeight , <nl> + availableWidth ) ; <nl> + } else if ( innerWidth < = 0 . 0f | | innerHeight < = 0 . 0f ) { <nl> / / Don ' t bother sizing the text if there ' s no horizontal or vertical <nl> / / space . <nl> node - > layout . measuredDimensions [ YGDimensionWidth ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionRow , 0 ) ; <nl> + YGNodeBoundAxis ( node , YGFlexDirectionRow , 0 . 0f , availableWidth , availableWidth ) ; <nl> node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionColumn , 0 ) ; <nl> + YGNodeBoundAxis ( node , YGFlexDirectionColumn , 0 . 0f , availableHeight , availableWidth ) ; <nl> } else { <nl> / / Measure the text under the current constraints . <nl> const YGSize measuredSize = <nl> static void YGNodeWithMeasureFuncSetMeasuredDimensions ( const YGNodeRef node , <nl> ( widthMeasureMode = = YGMeasureModeUndefined | | <nl> widthMeasureMode = = YGMeasureModeAtMost ) <nl> ? measuredSize . width + paddingAndBorderAxisRow <nl> - : availableWidth - marginAxisRow ) ; <nl> + : availableWidth - marginAxisRow , <nl> + availableWidth , <nl> + availableWidth ) ; <nl> node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> YGNodeBoundAxis ( node , <nl> YGFlexDirectionColumn , <nl> ( heightMeasureMode = = YGMeasureModeUndefined | | <nl> heightMeasureMode = = YGMeasureModeAtMost ) <nl> ? measuredSize . height + paddingAndBorderAxisColumn <nl> - : availableHeight - marginAxisColumn ) ; <nl> + : availableHeight - marginAxisColumn , <nl> + availableHeight , <nl> + availableWidth ) ; <nl> } <nl> } <nl> <nl> static void YGNodeEmptyContainerSetMeasuredDimensions ( const YGNodeRef node , <nl> const float availableWidth , <nl> const float availableHeight , <nl> const YGMeasureMode widthMeasureMode , <nl> - const YGMeasureMode heightMeasureMode ) { <nl> - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionRow ) ; <nl> + const YGMeasureMode heightMeasureMode , <nl> + const float parentWidth , <nl> + const float parentHeight ) { <nl> + const float paddingAndBorderAxisRow = <nl> + YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionRow , parentWidth ) ; <nl> const float paddingAndBorderAxisColumn = <nl> - YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionColumn ) ; <nl> - const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> - const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> + YGNodePaddingAndBorderForAxis ( node , YGFlexDirectionColumn , parentWidth ) ; <nl> + const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow , parentWidth ) ; <nl> + const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn , parentWidth ) ; <nl> <nl> node - > layout . measuredDimensions [ YGDimensionWidth ] = <nl> YGNodeBoundAxis ( node , <nl> static void YGNodeEmptyContainerSetMeasuredDimensions ( const YGNodeRef node , <nl> ( widthMeasureMode = = YGMeasureModeUndefined | | <nl> widthMeasureMode = = YGMeasureModeAtMost ) <nl> ? paddingAndBorderAxisRow <nl> - : availableWidth - marginAxisRow ) ; <nl> + : availableWidth - marginAxisRow , <nl> + parentWidth , <nl> + parentWidth ) ; <nl> node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> YGNodeBoundAxis ( node , <nl> YGFlexDirectionColumn , <nl> ( heightMeasureMode = = YGMeasureModeUndefined | | <nl> heightMeasureMode = = YGMeasureModeAtMost ) <nl> ? paddingAndBorderAxisColumn <nl> - : availableHeight - marginAxisColumn ) ; <nl> + : availableHeight - marginAxisColumn , <nl> + parentHeight , <nl> + parentWidth ) ; <nl> } <nl> <nl> static bool YGNodeFixedSizeSetMeasuredDimensions ( const YGNodeRef node , <nl> const float availableWidth , <nl> const float availableHeight , <nl> const YGMeasureMode widthMeasureMode , <nl> - const YGMeasureMode heightMeasureMode ) { <nl> - if ( ( widthMeasureMode = = YGMeasureModeAtMost & & availableWidth < = 0 ) | | <nl> - ( heightMeasureMode = = YGMeasureModeAtMost & & availableHeight < = 0 ) | | <nl> + const YGMeasureMode heightMeasureMode , <nl> + const float parentWidth , <nl> + const float parentHeight ) { <nl> + if ( ( widthMeasureMode = = YGMeasureModeAtMost & & availableWidth < = 0 . 0f ) | | <nl> + ( heightMeasureMode = = YGMeasureModeAtMost & & availableHeight < = 0 . 0f ) | | <nl> ( widthMeasureMode = = YGMeasureModeExactly & & heightMeasureMode = = YGMeasureModeExactly ) ) { <nl> - const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> - const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> + const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn , parentWidth ) ; <nl> + const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow , parentWidth ) ; <nl> <nl> node - > layout . measuredDimensions [ YGDimensionWidth ] = <nl> YGNodeBoundAxis ( node , <nl> YGFlexDirectionRow , <nl> - YGValueIsUndefined ( availableWidth ) | | ( widthMeasureMode = = YGMeasureModeAtMost & & availableWidth < 0 ) <nl> - ? 0 <nl> - : availableWidth - marginAxisRow ) ; <nl> + YGFloatIsUndefined ( availableWidth ) | | <nl> + ( widthMeasureMode = = YGMeasureModeAtMost & & availableWidth < 0 . 0f ) <nl> + ? 0 . 0f <nl> + : availableWidth - marginAxisRow , <nl> + parentWidth , <nl> + parentWidth ) ; <nl> <nl> node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> YGNodeBoundAxis ( node , <nl> YGFlexDirectionColumn , <nl> - YGValueIsUndefined ( availableHeight ) | | ( heightMeasureMode = = YGMeasureModeAtMost & & availableHeight < 0 ) <nl> - ? 0 <nl> - : availableHeight - marginAxisColumn ) ; <nl> + YGFloatIsUndefined ( availableHeight ) | | <nl> + ( heightMeasureMode = = YGMeasureModeAtMost & & availableHeight < 0 . 0f ) <nl> + ? 0 . 0f <nl> + : availableHeight - marginAxisColumn , <nl> + parentHeight , <nl> + parentWidth ) ; <nl> <nl> return true ; <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> const YGDirection parentDirection , <nl> const YGMeasureMode widthMeasureMode , <nl> const YGMeasureMode heightMeasureMode , <nl> + const float parentWidth , <nl> + const float parentHeight , <nl> const bool performLayout ) { <nl> - YG_ASSERT ( YGValueIsUndefined ( availableWidth ) ? widthMeasureMode = = YGMeasureModeUndefined : true , <nl> + YG_ASSERT ( YGFloatIsUndefined ( availableWidth ) ? widthMeasureMode = = YGMeasureModeUndefined : true , <nl> " availableWidth is indefinite so widthMeasureMode must be " <nl> " YGMeasureModeUndefined " ) ; <nl> - YG_ASSERT ( YGValueIsUndefined ( availableHeight ) ? heightMeasureMode = = YGMeasureModeUndefined <nl> + YG_ASSERT ( YGFloatIsUndefined ( availableHeight ) ? heightMeasureMode = = YGMeasureModeUndefined <nl> : true , <nl> " availableHeight is indefinite so heightMeasureMode must be " <nl> " YGMeasureModeUndefined " ) ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> <nl> const uint32_t childCount = YGNodeListCount ( node - > children ) ; <nl> if ( childCount = = 0 ) { <nl> - YGNodeEmptyContainerSetMeasuredDimensions ( <nl> - node , availableWidth , availableHeight , widthMeasureMode , heightMeasureMode ) ; <nl> + YGNodeEmptyContainerSetMeasuredDimensions ( node , <nl> + availableWidth , <nl> + availableHeight , <nl> + widthMeasureMode , <nl> + heightMeasureMode , <nl> + parentWidth , <nl> + parentHeight ) ; <nl> return ; <nl> } <nl> <nl> / / If we ' re not being asked to perform a full layout we can skip the algorithm if we already know <nl> / / the size <nl> - if ( ! performLayout & & <nl> - YGNodeFixedSizeSetMeasuredDimensions ( <nl> - node , availableWidth , availableHeight , widthMeasureMode , heightMeasureMode ) ) { <nl> + if ( ! performLayout & & YGNodeFixedSizeSetMeasuredDimensions ( node , <nl> + availableWidth , <nl> + availableHeight , <nl> + widthMeasureMode , <nl> + heightMeasureMode , <nl> + parentWidth , <nl> + parentHeight ) ) { <nl> return ; <nl> } <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> const YGJustify justifyContent = node - > style . justifyContent ; <nl> const bool isNodeFlexWrap = node - > style . flexWrap = = YGWrapWrap ; <nl> <nl> + const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight ; <nl> + const float crossAxisParentSize = isMainAxisRow ? parentHeight : parentWidth ; <nl> + <nl> YGNodeRef firstAbsoluteChild = NULL ; <nl> YGNodeRef currentAbsoluteChild = NULL ; <nl> <nl> - const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder ( node , mainAxis ) ; <nl> - const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder ( node , mainAxis ) ; <nl> - const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder ( node , crossAxis ) ; <nl> - const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis ( node , mainAxis ) ; <nl> - const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis ( node , crossAxis ) ; <nl> + const float leadingPaddingAndBorderMain = <nl> + YGNodeLeadingPaddingAndBorder ( node , mainAxis , parentWidth ) ; <nl> + const float trailingPaddingAndBorderMain = <nl> + YGNodeTrailingPaddingAndBorder ( node , mainAxis , parentWidth ) ; <nl> + const float leadingPaddingAndBorderCross = <nl> + YGNodeLeadingPaddingAndBorder ( node , crossAxis , parentWidth ) ; <nl> + const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis ( node , mainAxis , parentWidth ) ; <nl> + const float paddingAndBorderAxisCross = <nl> + YGNodePaddingAndBorderForAxis ( node , crossAxis , parentWidth ) ; <nl> <nl> const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode ; <nl> const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode ; <nl> <nl> - const float paddingAndBorderAxisRow = isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross ; <nl> - const float paddingAndBorderAxisColumn = isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain ; <nl> + const float paddingAndBorderAxisRow = <nl> + isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross ; <nl> + const float paddingAndBorderAxisColumn = <nl> + isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain ; <nl> <nl> - const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> - const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> + const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow , parentWidth ) ; <nl> + const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn , parentWidth ) ; <nl> <nl> / / STEP 2 : DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS <nl> - float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow ; <nl> - const float minInnerWidth = node - > style . minDimensions [ YGDimensionWidth ] - marginAxisRow - paddingAndBorderAxisRow ; <nl> - const float maxInnerWidth = node - > style . maxDimensions [ YGDimensionWidth ] - marginAxisRow - paddingAndBorderAxisRow ; <nl> - float availableInnerHeight = <nl> - availableHeight - marginAxisColumn - paddingAndBorderAxisColumn ; <nl> - const float minInnerHeight = node - > style . minDimensions [ YGDimensionHeight ] - marginAxisColumn - paddingAndBorderAxisColumn ; <nl> - const float maxInnerHeight = node - > style . maxDimensions [ YGDimensionHeight ] - marginAxisColumn - paddingAndBorderAxisColumn ; <nl> + const float minInnerWidth = <nl> + YGValueResolve ( & node - > style . minDimensions [ YGDimensionWidth ] , parentWidth ) - marginAxisRow - <nl> + paddingAndBorderAxisRow ; <nl> + const float maxInnerWidth = <nl> + YGValueResolve ( & node - > style . maxDimensions [ YGDimensionWidth ] , parentWidth ) - marginAxisRow - <nl> + paddingAndBorderAxisRow ; <nl> + const float minInnerHeight = <nl> + YGValueResolve ( & node - > style . minDimensions [ YGDimensionHeight ] , parentHeight ) - <nl> + marginAxisColumn - paddingAndBorderAxisColumn ; <nl> + const float maxInnerHeight = <nl> + YGValueResolve ( & node - > style . maxDimensions [ YGDimensionHeight ] , parentHeight ) - <nl> + marginAxisColumn - paddingAndBorderAxisColumn ; <nl> const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight ; <nl> const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight ; <nl> <nl> - / / Max dimension overrides predefined dimension value ; Min dimension in turn overrides both of the above <nl> - if ( ! YGValueIsUndefined ( availableInnerWidth ) ) { <nl> + / / Max dimension overrides predefined dimension value ; Min dimension in turn overrides both of the <nl> + / / above <nl> + float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow ; <nl> + if ( ! YGFloatIsUndefined ( availableInnerWidth ) ) { <nl> availableInnerWidth = fmaxf ( fminf ( availableInnerWidth , maxInnerWidth ) , minInnerWidth ) ; <nl> } <nl> - if ( ! YGValueIsUndefined ( availableInnerHeight ) ) { <nl> + <nl> + float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn ; <nl> + if ( ! YGFloatIsUndefined ( availableInnerHeight ) ) { <nl> availableInnerHeight = fmaxf ( fminf ( availableInnerHeight , maxInnerHeight ) , minInnerHeight ) ; <nl> } <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> singleFlexChild = NULL ; <nl> break ; <nl> } <nl> - } else if ( YGNodeStyleGetFlexGrow ( child ) > 0 & & YGNodeStyleGetFlexShrink ( child ) > 0 ) { <nl> + } else if ( YGNodeStyleGetFlexGrow ( child ) > 0 . 0f & & YGNodeStyleGetFlexShrink ( child ) > 0 . 0f ) { <nl> singleFlexChild = child ; <nl> } <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> if ( performLayout ) { <nl> / / Set the initial position ( relative to the parent ) . <nl> const YGDirection childDirection = YGNodeResolveDirection ( child , direction ) ; <nl> - YGNodeSetPosition ( child , childDirection ) ; <nl> + YGNodeSetPosition ( child , <nl> + childDirection , <nl> + availableInnerMainDim , <nl> + availableInnerCrossDim , <nl> + availableInnerWidth ) ; <nl> } <nl> <nl> / / Absolute - positioned children don ' t participate in flex layout . Add them <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> availableInnerWidth , <nl> widthMeasureMode , <nl> availableInnerHeight , <nl> + availableInnerWidth , <nl> + availableInnerHeight , <nl> heightMeasureMode , <nl> direction ) ; <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> child - > lineIndex = lineCount ; <nl> <nl> if ( child - > style . positionType ! = YGPositionTypeAbsolute ) { <nl> - const float outerFlexBasis = <nl> - child - > layout . computedFlexBasis + YGNodeMarginForAxis ( child , mainAxis ) ; <nl> + const float outerFlexBasis = child - > layout . computedFlexBasis + <nl> + YGNodeMarginForAxis ( child , mainAxis , availableInnerWidth ) ; <nl> <nl> / / If this is a multi - line flow and this item pushes us over the <nl> / / available size , we ' ve <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / the line length , so there ' s no more space left to distribute . <nl> <nl> / / We resolve main dimension to fit minimum and maximum values <nl> - if ( YGValueIsUndefined ( availableInnerMainDim ) ) { <nl> - if ( ! YGValueIsUndefined ( minInnerMainDim ) & & <nl> - sizeConsumedOnCurrentLine < minInnerMainDim ) { <nl> + if ( YGFloatIsUndefined ( availableInnerMainDim ) ) { <nl> + if ( ! YGFloatIsUndefined ( minInnerMainDim ) & & sizeConsumedOnCurrentLine < minInnerMainDim ) { <nl> availableInnerMainDim = minInnerMainDim ; <nl> - } else if ( ! YGValueIsUndefined ( maxInnerMainDim ) & & <nl> + } else if ( ! YGFloatIsUndefined ( maxInnerMainDim ) & & <nl> sizeConsumedOnCurrentLine > maxInnerMainDim ) { <nl> availableInnerMainDim = maxInnerMainDim ; <nl> } <nl> } <nl> <nl> float remainingFreeSpace = 0 ; <nl> - if ( ! YGValueIsUndefined ( availableInnerMainDim ) ) { <nl> + if ( ! YGFloatIsUndefined ( availableInnerMainDim ) ) { <nl> remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine ; <nl> } else if ( sizeConsumedOnCurrentLine < 0 ) { <nl> / / availableInnerMainDim is indefinite which means the node is being sized <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> baseMainSize = <nl> childFlexBasis + <nl> remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor ; <nl> - boundMainSize = YGNodeBoundAxis ( currentRelativeChild , mainAxis , baseMainSize ) ; <nl> + boundMainSize = YGNodeBoundAxis ( currentRelativeChild , <nl> + mainAxis , <nl> + baseMainSize , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> if ( baseMainSize ! = boundMainSize ) { <nl> / / By excluding this item ' s size and flex factor from remaining , <nl> / / this item ' s <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> if ( flexGrowFactor ! = 0 ) { <nl> baseMainSize = <nl> childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor ; <nl> - boundMainSize = YGNodeBoundAxis ( currentRelativeChild , mainAxis , baseMainSize ) ; <nl> + boundMainSize = YGNodeBoundAxis ( currentRelativeChild , <nl> + mainAxis , <nl> + baseMainSize , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> if ( baseMainSize ! = boundMainSize ) { <nl> / / By excluding this item ' s size and flex factor from remaining , <nl> / / this item ' s <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> ( remainingFreeSpace / totalFlexShrinkScaledFactors ) * flexShrinkScaledFactor ; <nl> } <nl> <nl> - updatedMainSize = YGNodeBoundAxis ( currentRelativeChild , mainAxis , childSize ) ; <nl> + updatedMainSize = YGNodeBoundAxis ( currentRelativeChild , <nl> + mainAxis , <nl> + childSize , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> } <nl> } else if ( remainingFreeSpace > 0 ) { <nl> flexGrowFactor = YGNodeStyleGetFlexGrow ( currentRelativeChild ) ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> YGNodeBoundAxis ( currentRelativeChild , <nl> mainAxis , <nl> childFlexBasis + <nl> - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor ) ; <nl> + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> } <nl> } <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> <nl> if ( isMainAxisRow ) { <nl> childWidth = <nl> - updatedMainSize + YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionRow ) ; <nl> + updatedMainSize + <nl> + YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionRow , availableInnerWidth ) ; <nl> childWidthMeasureMode = YGMeasureModeExactly ; <nl> <nl> - if ( ! YGValueIsUndefined ( availableInnerCrossDim ) & & <nl> + if ( ! YGFloatIsUndefined ( availableInnerCrossDim ) & & <nl> ! YGNodeIsStyleDimDefined ( currentRelativeChild , YGFlexDirectionColumn ) & & <nl> heightMeasureMode = = YGMeasureModeExactly & & <nl> YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch ) { <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } else if ( ! YGNodeIsStyleDimDefined ( currentRelativeChild , YGFlexDirectionColumn ) ) { <nl> childHeight = availableInnerCrossDim ; <nl> childHeightMeasureMode = <nl> - YGValueIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeAtMost ; <nl> + YGFloatIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeAtMost ; <nl> } else { <nl> - childHeight = currentRelativeChild - > style . dimensions [ YGDimensionHeight ] + <nl> - YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionColumn ) ; <nl> + childHeight = YGValueResolve ( & currentRelativeChild - > style . dimensions [ YGDimensionHeight ] , <nl> + availableInnerHeight ) + <nl> + YGNodeMarginForAxis ( currentRelativeChild , <nl> + YGFlexDirectionColumn , <nl> + availableInnerWidth ) ; <nl> childHeightMeasureMode = YGMeasureModeExactly ; <nl> } <nl> } else { <nl> childHeight = <nl> - updatedMainSize + YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionColumn ) ; <nl> + updatedMainSize + <nl> + YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionColumn , availableInnerWidth ) ; <nl> childHeightMeasureMode = YGMeasureModeExactly ; <nl> <nl> - if ( ! YGValueIsUndefined ( availableInnerCrossDim ) & & <nl> + if ( ! YGFloatIsUndefined ( availableInnerCrossDim ) & & <nl> ! YGNodeIsStyleDimDefined ( currentRelativeChild , YGFlexDirectionRow ) & & <nl> widthMeasureMode = = YGMeasureModeExactly & & <nl> YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch ) { <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } else if ( ! YGNodeIsStyleDimDefined ( currentRelativeChild , YGFlexDirectionRow ) ) { <nl> childWidth = availableInnerCrossDim ; <nl> childWidthMeasureMode = <nl> - YGValueIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeAtMost ; <nl> + YGFloatIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeAtMost ; <nl> } else { <nl> - childWidth = currentRelativeChild - > style . dimensions [ YGDimensionWidth ] + <nl> - YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionRow ) ; <nl> + childWidth = <nl> + YGValueResolve ( & currentRelativeChild - > style . dimensions [ YGDimensionWidth ] , <nl> + availableInnerWidth ) + <nl> + YGNodeMarginForAxis ( currentRelativeChild , YGFlexDirectionRow , availableInnerWidth ) ; <nl> childWidthMeasureMode = YGMeasureModeExactly ; <nl> } <nl> } <nl> <nl> - if ( ! YGValueIsUndefined ( currentRelativeChild - > style . aspectRatio ) ) { <nl> + if ( ! YGFloatIsUndefined ( currentRelativeChild - > style . aspectRatio ) ) { <nl> if ( isMainAxisRow ) { <nl> - childHeight = <nl> - fmaxf ( childWidth / currentRelativeChild - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( currentRelativeChild , YGFlexDirectionColumn ) ) ; <nl> + childHeight = fmaxf ( childWidth / currentRelativeChild - > style . aspectRatio , <nl> + YGNodePaddingAndBorderForAxis ( currentRelativeChild , <nl> + YGFlexDirectionColumn , <nl> + availableInnerWidth ) ) ; <nl> childHeightMeasureMode = YGMeasureModeExactly ; <nl> <nl> childHeight = fminf ( childHeight , availableInnerHeight ) ; <nl> childWidth = childHeight * currentRelativeChild - > style . aspectRatio ; <nl> } else { <nl> - childWidth = <nl> - fmaxf ( childHeight * currentRelativeChild - > style . aspectRatio , <nl> - YGNodePaddingAndBorderForAxis ( currentRelativeChild , YGFlexDirectionRow ) ) ; <nl> + childWidth = fmaxf ( childHeight * currentRelativeChild - > style . aspectRatio , <nl> + YGNodePaddingAndBorderForAxis ( currentRelativeChild , <nl> + YGFlexDirectionRow , <nl> + availableInnerWidth ) ) ; <nl> childWidthMeasureMode = YGMeasureModeExactly ; <nl> <nl> childWidth = fminf ( childWidth , availableInnerWidth ) ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } <nl> } <nl> <nl> - YGConstrainMaxSizeForMode ( currentRelativeChild - > style . maxDimensions [ YGDimensionWidth ] , <nl> - & childWidthMeasureMode , <nl> - & childWidth ) ; <nl> - YGConstrainMaxSizeForMode ( currentRelativeChild - > style . maxDimensions [ YGDimensionHeight ] , <nl> - & childHeightMeasureMode , <nl> - & childHeight ) ; <nl> + YGConstrainMaxSizeForMode ( <nl> + YGValueResolve ( & currentRelativeChild - > style . maxDimensions [ YGDimensionWidth ] , <nl> + availableInnerWidth ) , <nl> + & childWidthMeasureMode , <nl> + & childWidth ) ; <nl> + YGConstrainMaxSizeForMode ( <nl> + YGValueResolve ( & currentRelativeChild - > style . maxDimensions [ YGDimensionHeight ] , <nl> + availableInnerHeight ) , <nl> + & childHeightMeasureMode , <nl> + & childHeight ) ; <nl> <nl> const bool requiresStretchLayout = <nl> ! YGNodeIsStyleDimDefined ( currentRelativeChild , crossAxis ) & & <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> direction , <nl> childWidthMeasureMode , <nl> childHeightMeasureMode , <nl> + availableInnerWidth , <nl> + availableInnerHeight , <nl> performLayout & & ! requiresStretchLayout , <nl> " flex " ) ; <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / constraint by the min size defined for the main axis . <nl> <nl> if ( measureModeMainDim = = YGMeasureModeAtMost & & remainingFreeSpace > 0 ) { <nl> - if ( ! YGValueIsUndefined ( node - > style . minDimensions [ dim [ mainAxis ] ] ) & & <nl> - node - > style . minDimensions [ dim [ mainAxis ] ] > = 0 ) { <nl> - remainingFreeSpace = fmaxf ( 0 , <nl> - node - > style . minDimensions [ dim [ mainAxis ] ] - <nl> - ( availableInnerMainDim - remainingFreeSpace ) ) ; <nl> + if ( node - > style . minDimensions [ dim [ mainAxis ] ] . unit ! = YGUnitUndefined & & <nl> + YGValueResolve ( & node - > style . minDimensions [ dim [ mainAxis ] ] , mainAxisParentSize ) > = 0 ) { <nl> + remainingFreeSpace = <nl> + fmaxf ( 0 , <nl> + YGValueResolve ( & node - > style . minDimensions [ dim [ mainAxis ] ] , mainAxisParentSize ) - <nl> + ( availableInnerMainDim - remainingFreeSpace ) ) ; <nl> } else { <nl> remainingFreeSpace = 0 ; <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / In case the child is position absolute and has left / top being <nl> / / defined , we override the position to whatever the user said <nl> / / ( and margin / border ) . <nl> - child - > layout . position [ pos [ mainAxis ] ] = YGNodeLeadingPosition ( child , mainAxis ) + <nl> - YGNodeLeadingBorder ( node , mainAxis ) + <nl> - YGNodeLeadingMargin ( child , mainAxis ) ; <nl> + child - > layout . position [ pos [ mainAxis ] ] = <nl> + YGNodeLeadingPosition ( child , mainAxis , availableInnerMainDim ) + <nl> + YGNodeLeadingBorder ( node , mainAxis ) + <nl> + YGNodeLeadingMargin ( child , mainAxis , availableInnerWidth ) ; <nl> } <nl> } else { <nl> / / Now that we placed the element , we need to update the variables . <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / If we skipped the flex step , then we can ' t rely on the <nl> / / measuredDims because <nl> / / they weren ' t computed . This means we can ' t call YGNodeDimWithMargin . <nl> - mainDim + = betweenMainDim + YGNodeMarginForAxis ( child , mainAxis ) + <nl> + mainDim + = betweenMainDim + YGNodeMarginForAxis ( child , mainAxis , availableInnerWidth ) + <nl> child - > layout . computedFlexBasis ; <nl> crossDim = availableInnerCrossDim ; <nl> } else { <nl> / / The main dimension is the sum of all the elements dimension plus <nl> / / the spacing . <nl> - mainDim + = betweenMainDim + YGNodeDimWithMargin ( child , mainAxis ) ; <nl> + mainDim + = betweenMainDim + YGNodeDimWithMargin ( child , mainAxis , availableInnerWidth ) ; <nl> <nl> / / The cross dimension is the max of the elements dimension since <nl> / / there <nl> / / can only be one element in that cross dimension . <nl> - crossDim = fmaxf ( crossDim , YGNodeDimWithMargin ( child , crossAxis ) ) ; <nl> + crossDim = fmaxf ( crossDim , YGNodeDimWithMargin ( child , crossAxis , availableInnerWidth ) ) ; <nl> } <nl> } else if ( performLayout ) { <nl> child - > layout . position [ pos [ mainAxis ] ] + = <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> if ( measureModeCrossDim = = YGMeasureModeUndefined | | <nl> measureModeCrossDim = = YGMeasureModeAtMost ) { <nl> / / Compute the cross axis from the max cross dimension of the children . <nl> - containerCrossAxis = YGNodeBoundAxis ( node , crossAxis , crossDim + paddingAndBorderAxisCross ) - <nl> + containerCrossAxis = YGNodeBoundAxis ( node , <nl> + crossAxis , <nl> + crossDim + paddingAndBorderAxisCross , <nl> + crossAxisParentSize , <nl> + parentWidth ) - <nl> paddingAndBorderAxisCross ; <nl> <nl> if ( measureModeCrossDim = = YGMeasureModeAtMost ) { <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } <nl> <nl> / / Clamp to the min / max size specified on the container . <nl> - crossDim = YGNodeBoundAxis ( node , crossAxis , crossDim + paddingAndBorderAxisCross ) - <nl> + crossDim = YGNodeBoundAxis ( node , <nl> + crossAxis , <nl> + crossDim + paddingAndBorderAxisCross , <nl> + crossAxisParentSize , <nl> + parentWidth ) - <nl> paddingAndBorderAxisCross ; <nl> <nl> / / STEP 7 : CROSS - AXIS ALIGNMENT <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / set , override all the previously computed positions to set it <nl> / / correctly . <nl> if ( YGNodeIsLeadingPosDefined ( child , crossAxis ) ) { <nl> - child - > layout . position [ pos [ crossAxis ] ] = YGNodeLeadingPosition ( child , crossAxis ) + <nl> - YGNodeLeadingBorder ( node , crossAxis ) + <nl> - YGNodeLeadingMargin ( child , crossAxis ) ; <nl> + child - > layout . position [ pos [ crossAxis ] ] = <nl> + YGNodeLeadingPosition ( child , crossAxis , availableInnerCrossDim ) + <nl> + YGNodeLeadingBorder ( node , crossAxis ) + <nl> + YGNodeLeadingMargin ( child , crossAxis , availableInnerWidth ) ; <nl> } else { <nl> child - > layout . position [ pos [ crossAxis ] ] = <nl> - YGNodeLeadingBorder ( node , crossAxis ) + YGNodeLeadingMargin ( child , crossAxis ) ; <nl> + YGNodeLeadingBorder ( node , crossAxis ) + <nl> + YGNodeLeadingMargin ( child , crossAxis , availableInnerWidth ) ; <nl> } <nl> } else { <nl> float leadingCrossDim = leadingPaddingAndBorderCross ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> <nl> if ( isMainAxisRow ) { <nl> childWidth = child - > layout . measuredDimensions [ YGDimensionWidth ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionRow ) ; <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionRow , availableInnerWidth ) ; <nl> <nl> - if ( ! YGValueIsUndefined ( child - > style . aspectRatio ) ) { <nl> + if ( ! YGFloatIsUndefined ( child - > style . aspectRatio ) ) { <nl> childHeight = childWidth / child - > style . aspectRatio ; <nl> } else { <nl> childHeight = crossDim ; <nl> } <nl> } else { <nl> childHeight = child - > layout . measuredDimensions [ YGDimensionHeight ] + <nl> - YGNodeMarginForAxis ( child , YGFlexDirectionColumn ) ; <nl> + YGNodeMarginForAxis ( child , YGFlexDirectionColumn , availableInnerWidth ) ; <nl> <nl> - if ( ! YGValueIsUndefined ( child - > style . aspectRatio ) ) { <nl> + if ( ! YGFloatIsUndefined ( child - > style . aspectRatio ) ) { <nl> childWidth = childHeight * child - > style . aspectRatio ; <nl> } else { <nl> childWidth = crossDim ; <nl> } <nl> } <nl> <nl> - YGConstrainMaxSizeForMode ( child - > style . maxDimensions [ YGDimensionWidth ] , <nl> + YGConstrainMaxSizeForMode ( YGValueResolve ( & child - > style . maxDimensions [ YGDimensionWidth ] , <nl> + availableInnerWidth ) , <nl> & childWidthMeasureMode , <nl> & childWidth ) ; <nl> - YGConstrainMaxSizeForMode ( child - > style . maxDimensions [ YGDimensionHeight ] , <nl> + YGConstrainMaxSizeForMode ( YGValueResolve ( & child - > style . maxDimensions [ YGDimensionHeight ] , <nl> + availableInnerHeight ) , <nl> & childHeightMeasureMode , <nl> & childHeight ) ; <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / no need to stretch . <nl> if ( ! isCrossSizeDefinite ) { <nl> childWidthMeasureMode = <nl> - YGValueIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> + YGFloatIsUndefined ( childWidth ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> childHeightMeasureMode = <nl> - YGValueIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> + YGFloatIsUndefined ( childHeight ) ? YGMeasureModeUndefined : YGMeasureModeExactly ; <nl> <nl> YGLayoutNodeInternal ( child , <nl> childWidth , <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> direction , <nl> childWidthMeasureMode , <nl> childHeightMeasureMode , <nl> + availableInnerWidth , <nl> + availableInnerHeight , <nl> true , <nl> " stretch " ) ; <nl> } <nl> } else if ( alignItem ! = YGAlignFlexStart ) { <nl> const float remainingCrossDim = <nl> - containerCrossAxis - YGNodeDimWithMargin ( child , crossAxis ) ; <nl> + containerCrossAxis - YGNodeDimWithMargin ( child , crossAxis , availableInnerWidth ) ; <nl> <nl> if ( alignItem = = YGAlignCenter ) { <nl> leadingCrossDim + = remainingCrossDim / 2 ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } <nl> <nl> / / STEP 8 : MULTI - LINE CONTENT ALIGNMENT <nl> - if ( lineCount > 1 & & performLayout & & ! YGValueIsUndefined ( availableInnerCrossDim ) ) { <nl> + if ( lineCount > 1 & & performLayout & & ! YGFloatIsUndefined ( availableInnerCrossDim ) ) { <nl> const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim ; <nl> <nl> float crossDimLead = 0 ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> if ( YGNodeIsLayoutDimDefined ( child , crossAxis ) ) { <nl> lineHeight = fmaxf ( lineHeight , <nl> child - > layout . measuredDimensions [ dim [ crossAxis ] ] + <nl> - YGNodeMarginForAxis ( child , crossAxis ) ) ; <nl> + YGNodeMarginForAxis ( child , crossAxis , availableInnerWidth ) ) ; <nl> } <nl> } <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> switch ( YGNodeAlignItem ( node , child ) ) { <nl> case YGAlignFlexStart : { <nl> child - > layout . position [ pos [ crossAxis ] ] = <nl> - currentLead + YGNodeLeadingMargin ( child , crossAxis ) ; <nl> + currentLead + YGNodeLeadingMargin ( child , crossAxis , availableInnerWidth ) ; <nl> break ; <nl> } <nl> case YGAlignFlexEnd : { <nl> child - > layout . position [ pos [ crossAxis ] ] = <nl> - currentLead + lineHeight - YGNodeTrailingMargin ( child , crossAxis ) - <nl> + currentLead + lineHeight - <nl> + YGNodeTrailingMargin ( child , crossAxis , availableInnerWidth ) - <nl> child - > layout . measuredDimensions [ dim [ crossAxis ] ] ; <nl> break ; <nl> } <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } <nl> case YGAlignStretch : { <nl> child - > layout . position [ pos [ crossAxis ] ] = <nl> - currentLead + YGNodeLeadingMargin ( child , crossAxis ) ; <nl> + currentLead + YGNodeLeadingMargin ( child , crossAxis , availableInnerWidth ) ; <nl> / / TODO ( prenaux ) : Correctly set the height of items with indefinite <nl> / / ( auto ) crossAxis dimension . <nl> break ; <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> } <nl> <nl> / / STEP 9 : COMPUTING FINAL DIMENSIONS <nl> - node - > layout . measuredDimensions [ YGDimensionWidth ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionRow , availableWidth - marginAxisRow ) ; <nl> - node - > layout . measuredDimensions [ YGDimensionHeight ] = <nl> - YGNodeBoundAxis ( node , YGFlexDirectionColumn , availableHeight - marginAxisColumn ) ; <nl> + node - > layout . measuredDimensions [ YGDimensionWidth ] = YGNodeBoundAxis ( <nl> + node , YGFlexDirectionRow , availableWidth - marginAxisRow , parentWidth , parentWidth ) ; <nl> + node - > layout . measuredDimensions [ YGDimensionHeight ] = YGNodeBoundAxis ( <nl> + node , YGFlexDirectionColumn , availableHeight - marginAxisColumn , parentHeight , parentWidth ) ; <nl> <nl> / / If the user didn ' t specify a width or height for the node , set the <nl> / / dimensions based on the children . <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / Clamp the size to the min / max size , if specified , and make sure it <nl> / / doesn ' t go below the padding and border amount . <nl> node - > layout . measuredDimensions [ dim [ mainAxis ] ] = <nl> - YGNodeBoundAxis ( node , mainAxis , maxLineMainDim ) ; <nl> + YGNodeBoundAxis ( node , mainAxis , maxLineMainDim , mainAxisParentSize , parentWidth ) ; <nl> } else if ( measureModeMainDim = = YGMeasureModeAtMost ) { <nl> - node - > layout . measuredDimensions [ dim [ mainAxis ] ] = <nl> - fmaxf ( fminf ( availableInnerMainDim + paddingAndBorderAxisMain , <nl> - YGNodeBoundAxisWithinMinAndMax ( node , mainAxis , maxLineMainDim ) ) , <nl> - paddingAndBorderAxisMain ) ; <nl> + node - > layout . measuredDimensions [ dim [ mainAxis ] ] = fmaxf ( <nl> + fminf ( availableInnerMainDim + paddingAndBorderAxisMain , <nl> + YGNodeBoundAxisWithinMinAndMax ( node , mainAxis , maxLineMainDim , mainAxisParentSize ) ) , <nl> + paddingAndBorderAxisMain ) ; <nl> } <nl> <nl> if ( measureModeCrossDim = = YGMeasureModeUndefined ) { <nl> / / Clamp the size to the min / max size , if specified , and make sure it <nl> / / doesn ' t go below the padding and border amount . <nl> node - > layout . measuredDimensions [ dim [ crossAxis ] ] = <nl> - YGNodeBoundAxis ( node , crossAxis , totalLineCrossDim + paddingAndBorderAxisCross ) ; <nl> + YGNodeBoundAxis ( node , <nl> + crossAxis , <nl> + totalLineCrossDim + paddingAndBorderAxisCross , <nl> + crossAxisParentSize , <nl> + parentWidth ) ; <nl> } else if ( measureModeCrossDim = = YGMeasureModeAtMost ) { <nl> node - > layout . measuredDimensions [ dim [ crossAxis ] ] = <nl> fmaxf ( fminf ( availableInnerCrossDim + paddingAndBorderAxisCross , <nl> YGNodeBoundAxisWithinMinAndMax ( node , <nl> crossAxis , <nl> - totalLineCrossDim + paddingAndBorderAxisCross ) ) , <nl> + totalLineCrossDim + paddingAndBorderAxisCross , <nl> + crossAxisParentSize ) ) , <nl> paddingAndBorderAxisCross ) ; <nl> } <nl> <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> / / STEP 10 : SIZING AND POSITIONING ABSOLUTE CHILDREN <nl> for ( currentAbsoluteChild = firstAbsoluteChild ; currentAbsoluteChild ! = NULL ; <nl> currentAbsoluteChild = currentAbsoluteChild - > nextChild ) { <nl> - YGNodeAbsoluteLayoutChild ( <nl> - node , currentAbsoluteChild , availableInnerWidth , widthMeasureMode , direction ) ; <nl> + YGNodeAbsoluteLayoutChild ( node , <nl> + currentAbsoluteChild , <nl> + availableInnerWidth , <nl> + widthMeasureMode , <nl> + availableInnerHeight , <nl> + direction ) ; <nl> } <nl> <nl> / / STEP 11 : SETTING TRAILING POSITIONS FOR CHILDREN <nl> bool YGLayoutNodeInternal ( const YGNodeRef node , <nl> const YGDirection parentDirection , <nl> const YGMeasureMode widthMeasureMode , <nl> const YGMeasureMode heightMeasureMode , <nl> + const float parentWidth , <nl> + const float parentHeight , <nl> const bool performLayout , <nl> const char * reason ) { <nl> YGLayout * layout = & node - > layout ; <nl> bool YGLayoutNodeInternal ( const YGNodeRef node , <nl> / / expensive to measure , so it ' s worth avoiding redundant measurements if at <nl> / / all possible . <nl> if ( node - > measure ) { <nl> - const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> - const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> + const float marginAxisRow = YGNodeMarginForAxis ( node , YGFlexDirectionRow , parentWidth ) ; <nl> + const float marginAxisColumn = YGNodeMarginForAxis ( node , YGFlexDirectionColumn , parentWidth ) ; <nl> <nl> / / First , try to use the layout cache . <nl> if ( YGNodeCanUseCachedMeasurement ( widthMeasureMode , <nl> bool YGLayoutNodeInternal ( const YGNodeRef node , <nl> parentDirection , <nl> widthMeasureMode , <nl> heightMeasureMode , <nl> + parentWidth , <nl> + parentHeight , <nl> performLayout ) ; <nl> <nl> if ( gPrintChanges ) { <nl> void YGNodeCalculateLayout ( const YGNodeRef node , <nl> YGMeasureMode widthMeasureMode = YGMeasureModeUndefined ; <nl> YGMeasureMode heightMeasureMode = YGMeasureModeUndefined ; <nl> <nl> - if ( ! YGValueIsUndefined ( width ) ) { <nl> + if ( ! YGFloatIsUndefined ( width ) ) { <nl> widthMeasureMode = YGMeasureModeExactly ; <nl> } else if ( YGNodeIsStyleDimDefined ( node , YGFlexDirectionRow ) ) { <nl> - width = node - > style . dimensions [ dim [ YGFlexDirectionRow ] ] + <nl> - YGNodeMarginForAxis ( node , YGFlexDirectionRow ) ; <nl> + width = YGValueResolve ( & node - > style . dimensions [ dim [ YGFlexDirectionRow ] ] , availableWidth ) + <nl> + YGNodeMarginForAxis ( node , YGFlexDirectionRow , availableWidth ) ; <nl> widthMeasureMode = YGMeasureModeExactly ; <nl> - } else if ( node - > style . maxDimensions [ YGDimensionWidth ] > = 0 . 0 ) { <nl> - width = node - > style . maxDimensions [ YGDimensionWidth ] ; <nl> + } else if ( YGValueResolve ( & node - > style . maxDimensions [ YGDimensionWidth ] , availableWidth ) > = 0 . 0f ) { <nl> + width = YGValueResolve ( & node - > style . maxDimensions [ YGDimensionWidth ] , availableWidth ) ; <nl> widthMeasureMode = YGMeasureModeAtMost ; <nl> } <nl> <nl> - if ( ! YGValueIsUndefined ( height ) ) { <nl> + if ( ! YGFloatIsUndefined ( height ) ) { <nl> heightMeasureMode = YGMeasureModeExactly ; <nl> } else if ( YGNodeIsStyleDimDefined ( node , YGFlexDirectionColumn ) ) { <nl> - height = node - > style . dimensions [ dim [ YGFlexDirectionColumn ] ] + <nl> - YGNodeMarginForAxis ( node , YGFlexDirectionColumn ) ; <nl> + height = YGValueResolve ( & node - > style . dimensions [ dim [ YGFlexDirectionColumn ] ] , availableHeight ) + <nl> + YGNodeMarginForAxis ( node , YGFlexDirectionColumn , availableWidth ) ; <nl> heightMeasureMode = YGMeasureModeExactly ; <nl> - } else if ( node - > style . maxDimensions [ YGDimensionHeight ] > = 0 . 0 ) { <nl> - height = node - > style . maxDimensions [ YGDimensionHeight ] ; <nl> + } else if ( YGValueResolve ( & node - > style . maxDimensions [ YGDimensionHeight ] , availableHeight ) > = <nl> + 0 . 0f ) { <nl> + height = YGValueResolve ( & node - > style . maxDimensions [ YGDimensionHeight ] , availableHeight ) ; <nl> heightMeasureMode = YGMeasureModeAtMost ; <nl> } <nl> <nl> void YGNodeCalculateLayout ( const YGNodeRef node , <nl> parentDirection , <nl> widthMeasureMode , <nl> heightMeasureMode , <nl> + availableWidth , <nl> + availableHeight , <nl> true , <nl> " initia " <nl> " l " ) ) { <nl> - YGNodeSetPosition ( node , node - > layout . direction ) ; <nl> + YGNodeSetPosition ( node , node - > layout . direction , availableWidth , availableHeight , availableWidth ) ; <nl> <nl> if ( YGIsExperimentalFeatureEnabled ( YGExperimentalFeatureRounding ) ) { <nl> roundToPixelGrid ( node ) ; <nl> mmm a / yoga / Yoga . h <nl> ppp b / yoga / Yoga . h <nl> typedef struct YGSize { <nl> float height ; <nl> } YGSize ; <nl> <nl> + typedef struct YGValue { <nl> + float value ; <nl> + YGUnit unit ; <nl> + } YGValue ; <nl> + <nl> typedef struct YGNode * YGNodeRef ; <nl> typedef YGSize ( * YGMeasureFunc ) ( YGNodeRef node , <nl> float width , <nl> WIN_EXPORT bool YGNodeIsDirty ( const YGNodeRef node ) ; <nl> <nl> WIN_EXPORT void YGNodePrint ( const YGNodeRef node , const YGPrintOptions options ) ; <nl> <nl> - WIN_EXPORT bool YGValueIsUndefined ( const float value ) ; <nl> + WIN_EXPORT bool YGFloatIsUndefined ( const float value ) ; <nl> <nl> WIN_EXPORT bool YGNodeCanUseCachedMeasurement ( const YGMeasureMode widthMode , <nl> const float width , <nl> WIN_EXPORT void YGNodeCopyStyle ( const YGNodeRef dstNode , const YGNodeRef srcNode <nl> WIN_EXPORT void YGNodeStyleSet # # name ( const YGNodeRef node , const type paramName ) ; \ <nl> WIN_EXPORT type YGNodeStyleGet # # name ( const YGNodeRef node ) ; <nl> <nl> + # define YG_NODE_STYLE_PROPERTY_UNIT ( type , name , paramName ) \ <nl> + WIN_EXPORT void YGNodeStyleSet # # name ( const YGNodeRef node , const float paramName ) ; \ <nl> + WIN_EXPORT void YGNodeStyleSet # # name # # Percent ( const YGNodeRef node , const float paramName ) ; \ <nl> + WIN_EXPORT type YGNodeStyleGet # # name ( const YGNodeRef node ) ; <nl> + <nl> # define YG_NODE_STYLE_EDGE_PROPERTY ( type , name , paramName ) \ <nl> WIN_EXPORT void YGNodeStyleSet # # name ( const YGNodeRef node , \ <nl> const YGEdge edge , \ <nl> const type paramName ) ; \ <nl> WIN_EXPORT type YGNodeStyleGet # # name ( const YGNodeRef node , const YGEdge edge ) ; <nl> <nl> + # define YG_NODE_STYLE_EDGE_PROPERTY_UNIT ( type , name , paramName ) \ <nl> + WIN_EXPORT void YGNodeStyleSet # # name ( const YGNodeRef node , \ <nl> + const YGEdge edge , \ <nl> + const float paramName ) ; \ <nl> + WIN_EXPORT void YGNodeStyleSet # # name # # Percent ( const YGNodeRef node , \ <nl> + const YGEdge edge , \ <nl> + const float paramName ) ; \ <nl> + WIN_EXPORT type YGNodeStyleGet # # name ( const YGNodeRef node , const YGEdge edge ) ; <nl> + <nl> # define YG_NODE_LAYOUT_PROPERTY ( type , name ) \ <nl> WIN_EXPORT type YGNodeLayoutGet # # name ( const YGNodeRef node ) ; <nl> <nl> YG_NODE_STYLE_PROPERTY ( YGOverflow , Overflow , overflow ) ; <nl> WIN_EXPORT void YGNodeStyleSetFlex ( const YGNodeRef node , const float flex ) ; <nl> YG_NODE_STYLE_PROPERTY ( float , FlexGrow , flexGrow ) ; <nl> YG_NODE_STYLE_PROPERTY ( float , FlexShrink , flexShrink ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , FlexBasis , flexBasis ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , FlexBasis , flexBasis ) ; <nl> <nl> - YG_NODE_STYLE_EDGE_PROPERTY ( float , Position , position ) ; <nl> - YG_NODE_STYLE_EDGE_PROPERTY ( float , Margin , margin ) ; <nl> - YG_NODE_STYLE_EDGE_PROPERTY ( float , Padding , padding ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT ( YGValue , Position , position ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT ( YGValue , Margin , margin ) ; <nl> + YG_NODE_STYLE_EDGE_PROPERTY_UNIT ( YGValue , Padding , padding ) ; <nl> YG_NODE_STYLE_EDGE_PROPERTY ( float , Border , border ) ; <nl> <nl> - YG_NODE_STYLE_PROPERTY ( float , Width , width ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , Height , height ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , MinWidth , minWidth ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , MinHeight , minHeight ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , MaxWidth , maxWidth ) ; <nl> - YG_NODE_STYLE_PROPERTY ( float , MaxHeight , maxHeight ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , Width , width ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , Height , height ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , MinWidth , minWidth ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , MinHeight , minHeight ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , MaxWidth , maxWidth ) ; <nl> + YG_NODE_STYLE_PROPERTY_UNIT ( YGValue , MaxHeight , maxHeight ) ; <nl> <nl> / / Yoga specific properties , not compatible with flexbox specification <nl> / / Aspect ratio control the size of the undefined dimension of a node . <nl> | Add feature to use percentage as value unit | facebook/yoga | a85bd4ad2a25acd29f07d5ba1a87b747d9fb7546 | 2017-01-02T13:24:35Z |
mmm a / src / wasm / baseline / arm / liftoff - assembler - arm . h <nl> ppp b / src / wasm / baseline / arm / liftoff - assembler - arm . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / arm64 / liftoff - assembler - arm64 . h <nl> ppp b / src / wasm / baseline / arm64 / liftoff - assembler - arm64 . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / ia32 / liftoff - assembler - ia32 . h <nl> ppp b / src / wasm / baseline / ia32 / liftoff - assembler - ia32 . h <nl> namespace wasm { <nl> <nl> namespace liftoff { <nl> <nl> + / / ebp - 8 holds the stack marker , ebp - 16 is the wasm context , first stack slot <nl> + / / is located at ebp - 24 . <nl> + constexpr int32_t kConstantStackSpace = 16 ; <nl> + constexpr int32_t kFirstStackSlotOffset = <nl> + kConstantStackSpace + LiftoffAssembler : : kStackSlotSize ; <nl> + <nl> inline Operand GetStackSlot ( uint32_t index ) { <nl> - / / ebp - 8 holds the stack marker , ebp - 16 is the wasm context , first stack slot <nl> - / / is located at ebp - 24 . <nl> - constexpr int32_t kFirstStackSlotOffset = - 24 ; <nl> return Operand ( <nl> - ebp , kFirstStackSlotOffset - index * LiftoffAssembler : : kStackSlotSize ) ; <nl> + ebp , - kFirstStackSlotOffset - index * LiftoffAssembler : : kStackSlotSize ) ; <nl> } <nl> <nl> / / TODO ( clemensh ) : Make this a constexpr variable once Operand is constexpr . <nl> static constexpr Register kCCallLastArgAddrReg = eax ; <nl> <nl> static constexpr DoubleRegister kScratchDoubleReg = xmm7 ; <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + uint32_t bytes = liftoff : : kConstantStackSpace + kStackSlotSize * stack_slots ; <nl> DCHECK_LE ( bytes , kMaxInt ) ; <nl> sub ( esp , Immediate ( bytes ) ) ; <nl> } <nl> mmm a / src / wasm / baseline / liftoff - compiler . cc <nl> ppp b / src / wasm / baseline / liftoff - compiler . cc <nl> class LiftoffCompiler { <nl> } <nl> __ EnterFrame ( StackFrame : : WASM_COMPILED ) ; <nl> __ set_has_frame ( true ) ; <nl> - __ ReserveStackSpace ( LiftoffAssembler : : kStackSlotSize * <nl> - __ GetTotalFrameSlotCount ( ) ) ; <nl> + __ ReserveStackSpace ( __ GetTotalFrameSlotCount ( ) ) ; <nl> / / Parameter 0 is the wasm context . <nl> uint32_t num_params = <nl> static_cast < uint32_t > ( call_desc_ - > ParameterCount ( ) ) - 1 ; <nl> mmm a / src / wasm / baseline / mips / liftoff - assembler - mips . h <nl> ppp b / src / wasm / baseline / mips / liftoff - assembler - mips . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / mips64 / liftoff - assembler - mips64 . h <nl> ppp b / src / wasm / baseline / mips64 / liftoff - assembler - mips64 . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / ppc / liftoff - assembler - ppc . h <nl> ppp b / src / wasm / baseline / ppc / liftoff - assembler - ppc . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / s390 / liftoff - assembler - s390 . h <nl> ppp b / src / wasm / baseline / s390 / liftoff - assembler - s390 . h <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { UNIMPLEMENTED ( ) ; } <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> void LiftoffAssembler : : LoadConstant ( LiftoffRegister reg , WasmValue value , <nl> RelocInfo : : Mode rmode ) { <nl> mmm a / src / wasm / baseline / x64 / liftoff - assembler - x64 . h <nl> ppp b / src / wasm / baseline / x64 / liftoff - assembler - x64 . h <nl> namespace wasm { <nl> <nl> namespace liftoff { <nl> <nl> + / / rbp - 8 holds the stack marker , rbp - 16 is the wasm context , first stack slot <nl> + / / is located at rbp - 24 . <nl> + constexpr int32_t kConstantStackSpace = 16 ; <nl> + constexpr int32_t kFirstStackSlotOffset = <nl> + kConstantStackSpace + LiftoffAssembler : : kStackSlotSize ; <nl> + <nl> inline Operand GetStackSlot ( uint32_t index ) { <nl> - / / rbp - 8 holds the stack marker , rbp - 16 is the wasm context , first stack slot <nl> - / / is located at rbp - 24 . <nl> - constexpr int32_t kFirstStackSlotOffset = - 24 ; <nl> return Operand ( <nl> - rbp , kFirstStackSlotOffset - index * LiftoffAssembler : : kStackSlotSize ) ; <nl> + rbp , - kFirstStackSlotOffset - index * LiftoffAssembler : : kStackSlotSize ) ; <nl> } <nl> <nl> / / TODO ( clemensh ) : Make this a constexpr variable once Operand is constexpr . <nl> static constexpr Register kCCallLastArgAddrReg = rax ; <nl> <nl> } / / namespace liftoff <nl> <nl> - void LiftoffAssembler : : ReserveStackSpace ( uint32_t bytes ) { <nl> + void LiftoffAssembler : : ReserveStackSpace ( uint32_t stack_slots ) { <nl> + uint32_t bytes = liftoff : : kConstantStackSpace + kStackSlotSize * stack_slots ; <nl> DCHECK_LE ( bytes , kMaxInt ) ; <nl> subp ( rsp , Immediate ( bytes ) ) ; <nl> } <nl> | [ Liftoff ] Fix stack space reservation | v8/v8 | 5c7b116199a99ee0b497809b1924afc55c4238de | 2018-01-24T16:57:23Z |
mmm a / xbmc / cores / VideoPlayer / Buffers / CMakeLists . txt <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / CMakeLists . txt <nl> set ( SOURCES VideoBuffer . cpp ) <nl> set ( HEADERS VideoBuffer . h ) <nl> <nl> if ( CORE_PLATFORM_NAME_LC STREQUAL gbm ) <nl> - list ( APPEND SOURCES VideoBufferDRMPRIME . cpp ) <nl> - list ( APPEND HEADERS VideoBufferDRMPRIME . h ) <nl> + list ( APPEND SOURCES VideoBufferDMA . cpp <nl> + VideoBufferDRMPRIME . cpp <nl> + VideoBufferPoolDMA . cpp ) <nl> + list ( APPEND HEADERS VideoBufferDMA . h <nl> + VideoBufferDRMPRIME . h <nl> + VideoBufferPoolDMA . h ) <nl> endif ( ) <nl> <nl> core_add_library ( videoplayer - buffers ) <nl> new file mode 100644 <nl> index 000000000000 . . fd7554dc30c5 <nl> mmm / dev / null <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / VideoBufferDMA . cpp <nl> <nl> + / * <nl> + * Copyright ( C ) 2005 - 2020 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> + # include " VideoBufferDMA . h " <nl> + <nl> + # include " ServiceBroker . h " <nl> + # include " utils / BufferObject . h " <nl> + # include " utils / log . h " <nl> + <nl> + extern " C " <nl> + { <nl> + # include < libavutil / imgutils . h > <nl> + # include < libavutil / pixdesc . h > <nl> + } <nl> + <nl> + CVideoBufferDMA : : CVideoBufferDMA ( IVideoBufferPool & pool , int id , uint32_t fourcc , uint64_t size ) <nl> + : CVideoBufferDRMPRIMEFFmpeg ( pool , id ) , <nl> + m_bo ( CBufferObject : : GetBufferObject ( true ) ) , <nl> + m_fourcc ( fourcc ) , <nl> + m_size ( size ) <nl> + { <nl> + } <nl> + <nl> + CVideoBufferDMA : : ~ CVideoBufferDMA ( ) <nl> + { <nl> + Destroy ( ) ; <nl> + } <nl> + <nl> + AVDRMFrameDescriptor * CVideoBufferDMA : : GetDescriptor ( ) const <nl> + { <nl> + return const_cast < AVDRMFrameDescriptor * > ( & m_descriptor ) ; <nl> + } <nl> + <nl> + uint8_t * CVideoBufferDMA : : GetMemPtr ( ) <nl> + { <nl> + return m_addr ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : GetPlanes ( uint8_t * ( & planes ) [ YuvImage : : MAX_PLANES ] ) <nl> + { <nl> + for ( uint32_t i = 0 ; i < YuvImage : : MAX_PLANES ; i + + ) <nl> + planes [ i ] = m_addr + m_offsets [ i ] ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : GetStrides ( int ( & strides ) [ YuvImage : : MAX_PLANES ] ) <nl> + { <nl> + for ( uint32_t i = 0 ; i < YuvImage : : MAX_PLANES ; i + + ) <nl> + strides [ i ] = m_strides [ i ] ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : SetDimensions ( int width , int height ) <nl> + { <nl> + SetDimensions ( width , height , m_strides , m_offsets ) ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : SetDimensions ( int width , <nl> + int height , <nl> + const int ( & strides ) [ YuvImage : : MAX_PLANES ] ) <nl> + { <nl> + SetDimensions ( width , height , strides , m_offsets ) ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : SetDimensions ( int width , <nl> + int height , <nl> + const int ( & strides ) [ YuvImage : : MAX_PLANES ] , <nl> + const int ( & planeOffsets ) [ YuvImage : : MAX_PLANES ] ) <nl> + { <nl> + m_width = width ; <nl> + m_height = height ; <nl> + <nl> + AVDRMFrameDescriptor * descriptor = & m_descriptor ; <nl> + descriptor - > nb_objects = 1 ; <nl> + descriptor - > objects [ 0 ] . fd = m_fd ; <nl> + descriptor - > nb_layers = 1 ; <nl> + <nl> + AVDRMLayerDescriptor * layer = & descriptor - > layers [ 0 ] ; <nl> + layer - > format = m_fourcc ; <nl> + layer - > nb_planes = m_planes ; <nl> + <nl> + for ( uint32_t i = 0 ; i < m_planes ; i + + ) <nl> + { <nl> + layer - > planes [ i ] . offset = planeOffsets [ i ] ; <nl> + layer - > planes [ i ] . pitch = strides [ i ] ; <nl> + } <nl> + <nl> + if ( CServiceBroker : : GetLogging ( ) . CanLogComponent ( LOGVIDEO ) ) <nl> + { <nl> + std : : string planeStr ; <nl> + for ( uint32_t plane = 0 ; plane < m_planes ; plane + + ) <nl> + planeStr . append ( fmt : : format ( " \ nplane [ { } ] : stride = { } \ toffset = { } " , plane , strides [ plane ] , <nl> + planeOffsets [ plane ] ) ) ; <nl> + <nl> + CLog : : Log ( LOGDEBUG , LOGVIDEO , " CVideoBufferDMA : : { } - frame layout id = { } fourcc = { } { } " , <nl> + __FUNCTION__ , m_id , m_fourcc , planeStr ) ; <nl> + } <nl> + } <nl> + <nl> + bool CVideoBufferDMA : : Alloc ( ) <nl> + { <nl> + if ( ! m_bo - > CreateBufferObject ( m_size ) ) <nl> + return false ; <nl> + <nl> + m_fd = m_bo - > GetFd ( ) ; <nl> + m_addr = m_bo - > GetMemory ( ) ; <nl> + m_planes = 3 ; / / CAddonVideoCodec only requests AV_PIX_FMT_YUV420P for now <nl> + <nl> + CLog : : Log ( LOGDEBUG , LOGVIDEO , " CVideoBufferDMA : : { } - id = { } fourcc = { } fd = { } size = { } addr = { } " , <nl> + __FUNCTION__ , m_id , m_fourcc , m_fd , m_size , fmt : : ptr ( m_addr ) ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : Export ( AVFrame * frame , uint32_t width , uint32_t height ) <nl> + { <nl> + m_planes = av_pix_fmt_count_planes ( static_cast < AVPixelFormat > ( frame - > format ) ) ; <nl> + <nl> + if ( m_planes < 2 ) <nl> + throw std : : runtime_error ( <nl> + " non - planar formats not supported : " + <nl> + std : : string ( av_get_pix_fmt_name ( static_cast < AVPixelFormat > ( frame - > format ) ) ) ) ; <nl> + <nl> + for ( uint32_t plane = 0 ; plane < m_planes ; plane + + ) <nl> + { <nl> + m_strides [ plane ] = <nl> + av_image_get_linesize ( static_cast < AVPixelFormat > ( frame - > format ) , width , plane ) ; <nl> + m_offsets [ plane ] = <nl> + plane = = 0 ? 0 : ( m_offsets [ plane - 1 ] + m_strides [ plane - 1 ] * ( height > > ( plane - 1 ) ) ) ; <nl> + } <nl> + <nl> + if ( CServiceBroker : : GetLogging ( ) . CanLogComponent ( LOGVIDEO ) ) <nl> + { <nl> + std : : string planeStr ; <nl> + for ( uint32_t plane = 0 ; plane < m_planes ; plane + + ) <nl> + planeStr . append ( fmt : : format ( " \ nplane [ { } ] : stride = { } \ toffset = { } " , plane , m_strides [ plane ] , <nl> + m_offsets [ plane ] ) ) ; <nl> + <nl> + CLog : : Log ( LOGDEBUG , LOGVIDEO , " CVideoBufferDMA : : { } - frame layout id = { } fourcc = { } { } " , <nl> + __FUNCTION__ , m_id , m_fourcc , planeStr ) ; <nl> + } <nl> + <nl> + for ( uint32_t i = 0 ; i < AV_NUM_DATA_POINTERS ; i + + ) <nl> + { <nl> + frame - > data [ i ] = i < m_planes ? m_addr + m_offsets [ i ] : nullptr ; <nl> + frame - > linesize [ i ] = i < m_planes ? m_strides [ i ] : 0 ; <nl> + frame - > buf [ i ] = i = = 0 ? frame - > opaque_ref : nullptr ; <nl> + } <nl> + <nl> + frame - > extended_data = frame - > data ; <nl> + frame - > opaque_ref = nullptr ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : SyncStart ( ) <nl> + { <nl> + m_bo - > SyncStart ( ) ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : SyncEnd ( ) <nl> + { <nl> + m_bo - > SyncEnd ( ) ; <nl> + } <nl> + <nl> + void CVideoBufferDMA : : Destroy ( ) <nl> + { <nl> + m_bo - > ReleaseMemory ( ) ; <nl> + m_bo - > DestroyBufferObject ( ) ; <nl> + <nl> + for ( auto & offset : m_offsets ) <nl> + offset = 0 ; <nl> + <nl> + for ( auto & stride : m_strides ) <nl> + stride = 0 ; <nl> + <nl> + m_planes = 0 ; <nl> + m_width = 0 ; <nl> + m_height = 0 ; <nl> + m_fourcc = 0 ; <nl> + m_size = 0 ; <nl> + m_addr = nullptr ; <nl> + m_fd = - 1 ; <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 94eb1c8a1606 <nl> mmm / dev / null <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / VideoBufferDMA . h <nl> <nl> + / * <nl> + * Copyright ( C ) 2005 - 2020 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> + # include " cores / VideoPlayer / Buffers / VideoBufferDRMPRIME . h " <nl> + <nl> + # include < memory > <nl> + <nl> + class IBufferObject ; <nl> + <nl> + class CVideoBufferDMA : public CVideoBufferDRMPRIMEFFmpeg <nl> + { <nl> + public : <nl> + CVideoBufferDMA ( IVideoBufferPool & pool , int id , uint32_t fourcc , uint64_t size ) ; <nl> + ~ CVideoBufferDMA ( ) override ; <nl> + <nl> + / / implementation of CVideoBufferDRMPRIME via CVideoBufferDRMPRIMEFFmpeg <nl> + uint32_t GetWidth ( ) const override { return m_width ; } <nl> + uint32_t GetHeight ( ) const override { return m_height ; } <nl> + AVDRMFrameDescriptor * GetDescriptor ( ) const override ; <nl> + <nl> + / / implementation of CVideoBuffer via CVideoBufferDRMPRIMEFFmpeg <nl> + void GetPlanes ( uint8_t * ( & planes ) [ YuvImage : : MAX_PLANES ] ) override ; <nl> + void GetStrides ( int ( & strides ) [ YuvImage : : MAX_PLANES ] ) override ; <nl> + uint8_t * GetMemPtr ( ) override ; <nl> + void SetDimensions ( int width , int height , const int ( & strides ) [ YuvImage : : MAX_PLANES ] ) override ; <nl> + void SetDimensions ( int width , <nl> + int height , <nl> + const int ( & strides ) [ YuvImage : : MAX_PLANES ] , <nl> + const int ( & planeOffsets ) [ YuvImage : : MAX_PLANES ] ) override ; <nl> + <nl> + void SetDimensions ( int width , int height ) ; <nl> + bool Alloc ( ) ; <nl> + void Export ( AVFrame * frame , uint32_t width , uint32_t height ) ; <nl> + <nl> + void SyncStart ( ) ; <nl> + void SyncEnd ( ) ; <nl> + <nl> + private : <nl> + void Destroy ( ) ; <nl> + <nl> + std : : unique_ptr < IBufferObject > m_bo ; <nl> + <nl> + int m_offsets [ YuvImage : : MAX_PLANES ] { 0 } ; <nl> + int m_strides [ YuvImage : : MAX_PLANES ] { 0 } ; <nl> + <nl> + AVDRMFrameDescriptor m_descriptor { } ; <nl> + uint32_t m_planes { 0 } ; <nl> + uint32_t m_width { 0 } ; <nl> + uint32_t m_height { 0 } ; <nl> + uint32_t m_fourcc { 0 } ; <nl> + uint64_t m_size { 0 } ; <nl> + uint8_t * m_addr { nullptr } ; <nl> + int m_fd { - 1 } ; <nl> + } ; <nl> mmm a / xbmc / cores / VideoPlayer / Buffers / VideoBufferDRMPRIME . h <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / VideoBufferDRMPRIME . h <nl> class CVideoBufferDRMPRIME : public CVideoBuffer <nl> <nl> virtual void SetPictureParams ( const VideoPicture & picture ) { m_picture . SetParams ( picture ) ; } <nl> virtual const VideoPicture & GetPicture ( ) const { return m_picture ; } <nl> - uint32_t GetWidth ( ) const { return GetPicture ( ) . iWidth ; } <nl> - uint32_t GetHeight ( ) const { return GetPicture ( ) . iHeight ; } <nl> + virtual uint32_t GetWidth ( ) const { return GetPicture ( ) . iWidth ; } <nl> + virtual uint32_t GetHeight ( ) const { return GetPicture ( ) . iHeight ; } <nl> <nl> virtual AVDRMFrameDescriptor * GetDescriptor ( ) const = 0 ; <nl> virtual bool IsValid ( ) const { return true ; } <nl> new file mode 100644 <nl> index 000000000000 . . dc020eaf130d <nl> mmm / dev / null <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / VideoBufferPoolDMA . cpp <nl> <nl> + / * <nl> + * Copyright ( C ) 2005 - 2020 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> + # include " VideoBufferPoolDMA . h " <nl> + <nl> + # include " cores / VideoPlayer / Buffers / VideoBufferDMA . h " <nl> + # include " threads / SingleLock . h " <nl> + # include " utils / BufferObjectFactory . h " <nl> + <nl> + # include < drm_fourcc . h > <nl> + <nl> + extern " C " <nl> + { <nl> + # include < libavutil / pixfmt . h > <nl> + } <nl> + <nl> + CVideoBufferPoolDMA : : ~ CVideoBufferPoolDMA ( ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + for ( auto buf : m_all ) <nl> + delete buf ; <nl> + } <nl> + <nl> + CVideoBuffer * CVideoBufferPoolDMA : : Get ( ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + CVideoBufferDMA * buf = nullptr ; <nl> + if ( ! m_free . empty ( ) ) <nl> + { <nl> + int idx = m_free . front ( ) ; <nl> + m_free . pop_front ( ) ; <nl> + m_used . push_back ( idx ) ; <nl> + buf = m_all [ idx ] ; <nl> + } <nl> + else <nl> + { <nl> + int id = m_all . size ( ) ; <nl> + buf = new CVideoBufferDMA ( * this , id , m_fourcc , m_size ) ; <nl> + <nl> + if ( ! buf - > Alloc ( ) ) <nl> + { <nl> + delete buf ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + m_all . push_back ( buf ) ; <nl> + m_used . push_back ( id ) ; <nl> + } <nl> + <nl> + buf - > Acquire ( GetPtr ( ) ) ; <nl> + return buf ; <nl> + } <nl> + <nl> + void CVideoBufferPoolDMA : : Return ( int id ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + m_all [ id ] - > Unref ( ) ; <nl> + auto it = m_used . begin ( ) ; <nl> + while ( it ! = m_used . end ( ) ) <nl> + { <nl> + if ( * it = = id ) <nl> + { <nl> + m_used . erase ( it ) ; <nl> + break ; <nl> + } <nl> + else <nl> + + + it ; <nl> + } <nl> + m_free . push_back ( id ) ; <nl> + } <nl> + <nl> + void CVideoBufferPoolDMA : : Configure ( AVPixelFormat format , int size ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + m_fourcc = TranslateFormat ( format ) ; <nl> + m_size = static_cast < uint64_t > ( size ) ; <nl> + } <nl> + <nl> + bool CVideoBufferPoolDMA : : IsConfigured ( ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + return ( m_fourcc ! = 0 & & m_size ! = 0 ) ; <nl> + } <nl> + <nl> + bool CVideoBufferPoolDMA : : IsCompatible ( AVPixelFormat format , int size ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + if ( m_fourcc ! = TranslateFormat ( format ) | | m_size ! = static_cast < uint64_t > ( size ) ) <nl> + return false ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void CVideoBufferPoolDMA : : Released ( CVideoBufferManager & videoBufferManager ) <nl> + { <nl> + if ( ! CBufferObjectFactory : : CreateBufferObject ( true ) ) <nl> + return ; <nl> + <nl> + videoBufferManager . RegisterPool ( std : : make_shared < CVideoBufferPoolDMA > ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < IVideoBufferPool > CVideoBufferPoolDMA : : CreatePool ( ) <nl> + { <nl> + return std : : make_shared < CVideoBufferPoolDMA > ( ) ; <nl> + } <nl> + <nl> + uint32_t CVideoBufferPoolDMA : : TranslateFormat ( AVPixelFormat format ) <nl> + { <nl> + switch ( format ) <nl> + { <nl> + case AV_PIX_FMT_YUV420P : <nl> + case AV_PIX_FMT_YUVJ420P : <nl> + return DRM_FORMAT_YUV420 ; <nl> + default : <nl> + return 0 ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . a490fcb62c3d <nl> mmm / dev / null <nl> ppp b / xbmc / cores / VideoPlayer / Buffers / VideoBufferPoolDMA . h <nl> <nl> + / * <nl> + * Copyright ( C ) 2005 - 2020 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> + # include " cores / VideoPlayer / Buffers / VideoBuffer . h " <nl> + <nl> + # include < memory > <nl> + <nl> + class CVideoBufferDMA ; <nl> + <nl> + class CVideoBufferPoolDMA : public IVideoBufferPool <nl> + { <nl> + public : <nl> + CVideoBufferPoolDMA ( ) = default ; <nl> + ~ CVideoBufferPoolDMA ( ) override ; <nl> + <nl> + / / implementation of IVideoBufferPool <nl> + CVideoBuffer * Get ( ) override ; <nl> + void Return ( int id ) override ; <nl> + void Configure ( AVPixelFormat format , int size ) override ; <nl> + bool IsConfigured ( ) override ; <nl> + bool IsCompatible ( AVPixelFormat format , int size ) override ; <nl> + void Released ( CVideoBufferManager & videoBufferManager ) override ; <nl> + <nl> + static std : : shared_ptr < IVideoBufferPool > CreatePool ( ) ; <nl> + <nl> + protected : <nl> + CCriticalSection m_critSection ; <nl> + std : : vector < CVideoBufferDMA * > m_all ; <nl> + std : : deque < int > m_used ; <nl> + std : : deque < int > m_free ; <nl> + <nl> + private : <nl> + uint32_t TranslateFormat ( AVPixelFormat format ) ; <nl> + <nl> + uint32_t m_fourcc = 0 ; <nl> + uint64_t m_size = 0 ; <nl> + } ; <nl> | CVideoBufferDMA : add class to use CBufferObject | xbmc/xbmc | 9c8e52d7372582fd230e82218f9324ddbd7d6550 | 2020-04-19T21:26:49Z |
mmm a / sw . cpp <nl> ppp b / sw . cpp <nl> void build ( Solution & s ) <nl> { <nl> libtesseract + = " __SSE4_1__ " _def ; <nl> libtesseract . CompileOptions . push_back ( " - arch : AVX2 " ) ; <nl> + <nl> + libtesseract - = <nl> + " src / arch / dotproductfma . cpp " ; <nl> } <nl> <nl> libtesseract . Public + = " HAVE_CONFIG_H " _d ; <nl> | [ build ] [ sw ] Disable FMA dotproduct . | tesseract-ocr/tesseract | dbba30b82fdeea806bdb1a0473b2842eace0a221 | 2019-07-13T17:03:53Z |
mmm a / tensorflow / tensorflow . bzl <nl> ppp b / tensorflow / tensorflow . bzl <nl> def tf_binary_additional_srcs ( ) : <nl> ] , <nl> ) <nl> <nl> + def _linux_kernel_dso_name ( kernel_build_target ) : <nl> + " " " Given a build target , construct the dso name for linux . " " " <nl> + parts = kernel_build_target . split ( " : " ) <nl> + return " % s : libtfkernel_ % s . so " % ( parts [ 0 ] , parts [ 1 ] ) <nl> + <nl> # Helper functions to add kernel dependencies to tf binaries when using dynamic <nl> # kernel linking . <nl> def tf_binary_dynamic_kernel_dsos ( kernels ) : <nl> return if_dynamic_kernels ( <nl> - extra_deps = [ " libtfkernel_ % s . so " % clean_dep ( k ) for k in kernels ] , <nl> + extra_deps = [ _linux_kernel_dso_name ( k ) for k in kernels ] , <nl> otherwise = [ ] , <nl> ) <nl> <nl> def tf_cuda_cc_test ( <nl> extra_copts = [ ] , <nl> linkstatic = 0 , <nl> args = [ ] , <nl> + kernels = [ ] , <nl> linkopts = [ ] ) : <nl> tf_cc_test ( <nl> name = name , <nl> def tf_cuda_cc_test ( <nl> linkstatic = linkstatic , <nl> linkopts = linkopts , <nl> args = args , <nl> + kernels = kernels , <nl> ) <nl> tf_cc_test ( <nl> name = name , <nl> def tf_cuda_cc_test ( <nl> extra_copts = extra_copts , <nl> linkopts = linkopts , <nl> args = args , <nl> + kernels = kernels , <nl> ) <nl> <nl> register_extension_info ( <nl> def tf_cc_tests ( <nl> size = " medium " , <nl> args = None , <nl> linkopts = [ ] , <nl> + kernels = [ ] , <nl> nocopts = None ) : <nl> for src in srcs : <nl> tf_cc_test ( <nl> def tf_cc_tests ( <nl> args = args , <nl> linkopts = linkopts , <nl> nocopts = nocopts , <nl> + kernels = kernels , <nl> ) <nl> <nl> def tf_cc_test_mkl ( <nl> def tf_cc_tests_gpu ( <nl> linkstatic = 0 , <nl> tags = [ ] , <nl> size = " medium " , <nl> + kernels = [ ] , <nl> args = None ) : <nl> - tf_cc_tests ( srcs , deps , linkstatic , tags = tags , size = size , args = args ) <nl> + tf_cc_tests ( srcs , deps , linkstatic , tags = tags , size = size , kernels = kernels , args = args ) <nl> <nl> def tf_cuda_cc_tests ( <nl> srcs , <nl> def tf_cuda_cc_tests ( <nl> size = " medium " , <nl> linkstatic = 0 , <nl> args = None , <nl> + kernels = [ ] , <nl> linkopts = [ ] ) : <nl> for src in srcs : <nl> tf_cuda_cc_test ( <nl> def tf_cuda_cc_tests ( <nl> size = size , <nl> linkstatic = linkstatic , <nl> args = args , <nl> + kernels = kernels , <nl> linkopts = linkopts , <nl> ) <nl> <nl> def tf_py_wrap_cc ( <nl> # Note that this only works on Windows . See the definition of <nl> # / / third_party / tensorflow / tools / pip_package : win_pip_package_marker for specific reasons . <nl> # 2 . When - - define = no_tensorflow_py_deps = false ( by default ) , it ' s a normal py_test . <nl> - def py_test ( deps = [ ] , data = [ ] , * * kwargs ) : <nl> + def py_test ( deps = [ ] , data = [ ] , kernels = [ ] , * * kwargs ) : <nl> native . py_test ( <nl> # TODO ( jlebar ) : Ideally we ' d use tcmalloc here . , <nl> deps = select ( { <nl> " / / conditions : default " : deps , <nl> clean_dep ( " / / tensorflow : no_tensorflow_py_deps " ) : [ ] , <nl> - } ) , <nl> + } ) + tf_binary_dynamic_kernel_deps ( kernels ) , <nl> data = data + select ( { <nl> " / / conditions : default " : [ ] , <nl> clean_dep ( " / / tensorflow : no_tensorflow_py_deps " ) : [ " / / tensorflow / tools / pip_package : win_pip_package_marker " ] , <nl> - } ) , <nl> + } ) + tf_binary_dynamic_kernel_dsos ( kernels ) , <nl> * * kwargs <nl> ) <nl> <nl> def tf_py_test ( <nl> tags = [ ] , <nl> shard_count = 1 , <nl> additional_deps = [ ] , <nl> + kernels = [ ] , <nl> flaky = 0 , <nl> xla_enabled = False , <nl> grpc_enabled = False ) : <nl> def tf_py_test ( <nl> tags = tags , <nl> visibility = [ clean_dep ( " / / tensorflow : internal " ) ] , <nl> shard_count = shard_count , <nl> + kernels = kernels , <nl> data = data , <nl> deps = [ <nl> clean_dep ( " / / tensorflow / python : extra_py_tests_deps " ) , <nl> def cuda_py_test ( <nl> args = [ ] , <nl> shard_count = 1 , <nl> additional_deps = [ ] , <nl> + kernels = [ ] , <nl> tags = [ ] , <nl> flaky = 0 , <nl> xla_enabled = False , <nl> def cuda_py_test ( <nl> tags = test_tags , <nl> shard_count = shard_count , <nl> additional_deps = additional_deps , <nl> + kernels = kernels , <nl> flaky = flaky , <nl> xla_enabled = xla_enabled , <nl> grpc_enabled = grpc_enabled , <nl> def sycl_py_test ( <nl> args = [ ] , <nl> shard_count = 1 , <nl> additional_deps = [ ] , <nl> + kernels = [ ] , <nl> tags = [ ] , <nl> flaky = 0 , <nl> xla_enabled = False , <nl> def sycl_py_test ( <nl> tags = test_tags , <nl> shard_count = shard_count , <nl> additional_deps = additional_deps , <nl> + kernels = kernels , <nl> flaky = flaky , <nl> xla_enabled = xla_enabled , <nl> grpc_enabled = grpc_enabled , <nl> def py_tests ( <nl> srcs , <nl> size = " medium " , <nl> additional_deps = [ ] , <nl> + kernels = [ ] , <nl> data = [ ] , <nl> tags = [ ] , <nl> shard_count = 1 , <nl> def py_tests ( <nl> shard_count = shard_count , <nl> data = data , <nl> additional_deps = additional_deps , <nl> + kernels = kernels , <nl> xla_enabled = xla_enabled , <nl> grpc_enabled = grpc_enabled , <nl> ) <nl> def cuda_py_tests ( <nl> srcs , <nl> size = " medium " , <nl> additional_deps = [ ] , <nl> + kernels = [ ] , <nl> data = [ ] , <nl> shard_count = 1 , <nl> tags = [ ] , <nl> def cuda_py_tests ( <nl> tags = test_tags , <nl> shard_count = shard_count , <nl> prefix = prefix , <nl> + kernels = kernels , <nl> xla_enabled = xla_enabled , <nl> grpc_enabled = grpc_enabled , <nl> ) <nl> | Add the kernels option to also the python binary macros defined in tensorflow . bzl | tensorflow/tensorflow | d004f08ee6102b2081a4ae14420e9eb76b1eb669 | 2018-08-30T07:12:48Z |
mmm a / benchmark / twitter / sax_tweet_reader_visitor . h <nl> ppp b / benchmark / twitter / sax_tweet_reader_visitor . h <nl> simdjson_really_inline void sax_tweet_reader_visitor : : field_lookup : : neg ( const ch <nl> auto index = hash ( key , depth ) ; <nl> if ( entries [ index ] . key ) { <nl> fprintf ( stderr , " % s ( depth % d ) conflicts with % s ( depth % d ) ! \ n " , key , depth , entries [ index ] . key , int ( entries [ index ] . container ) ) ; <nl> - assert ( false ) ; <nl> } <nl> } <nl> <nl> mmm a / src / generic / ondemand / array - inl . h <nl> ppp b / src / generic / ondemand / array - inl . h <nl> namespace ondemand { <nl> / / <nl> / / # # # Live States <nl> / / <nl> - / / While iterating or looking up values , depth > = doc - > iter . depth . at_start may vary . Error is <nl> + / / While iterating or looking up values , depth > = iter - > depth . at_start may vary . Error is <nl> / / always SUCCESS : <nl> / / <nl> / / - Start : This is the state when the array is first found and the iterator is just past the ` { ` . <nl> / / In this state , at_start = = true . <nl> / / - Next : After we hand a scalar value to the user , or an array / object which they then fully <nl> / / iterate over , the iterator is at the ` , ` before the next value ( or ` ] ` ) . In this state , <nl> - / / depth = = doc - > iter . depth , at_start = = false , and error = = SUCCESS . <nl> + / / depth = = iter - > depth , at_start = = false , and error = = SUCCESS . <nl> / / - Unfinished Business : When we hand an array / object to the user which they do not fully <nl> / / iterate over , we need to finish that iteration by skipping child values until we reach the <nl> - / / Next state . In this state , depth > doc - > iter . depth , at_start = = false , and error = = SUCCESS . <nl> + / / Next state . In this state , depth > iter - > depth , at_start = = false , and error = = SUCCESS . <nl> / / <nl> / / # # Error States <nl> / / <nl> - / / In error states , we will yield exactly one more value before stopping . doc - > iter . depth = = depth <nl> + / / In error states , we will yield exactly one more value before stopping . iter - > depth = = depth <nl> / / and at_start is always false . We decrement after yielding the error , moving to the Finished <nl> / / state . <nl> / / <nl> / / - Chained Error : When the array iterator is part of an error chain - - for example , in <nl> / / ` for ( auto tweet : doc [ " tweets " ] ) ` , where the tweet element may be missing or not be an <nl> / / array - - we yield that error in the loop , exactly once . In this state , error ! = SUCCESS and <nl> - / / doc - > iter . depth = = depth , and at_start = = false . We decrement depth when we yield the error . <nl> + / / iter - > depth = = depth , and at_start = = false . We decrement depth when we yield the error . <nl> / / - Missing Comma Error : When the iterator + + method discovers there is no comma between elements , <nl> / / we flag that as an error and treat it exactly the same as a Chained Error . In this state , <nl> - / / error = = TAPE_ERROR , doc - > iter . depth = = depth , and at_start = = false . <nl> + / / error = = TAPE_ERROR , iter - > depth = = depth , and at_start = = false . <nl> / / <nl> / / # # Terminal State <nl> / / <nl> - / / The terminal state has doc - > iter . depth < depth . at_start is always false . <nl> + / / The terminal state has iter - > depth < depth . at_start is always false . <nl> / / <nl> / / - Finished : When we have reached a ` ] ` or have reported an error , we are finished . We signal this <nl> - / / by decrementing depth . In this state , doc - > iter . depth < depth , at_start = = false , and <nl> + / / by decrementing depth . In this state , iter - > depth < depth , at_start = = false , and <nl> / / error = = SUCCESS . <nl> / / <nl> <nl> simdjson_really_inline array : : array ( ) noexcept = default ; <nl> - simdjson_really_inline array : : array ( document * _doc , bool has_value ) noexcept <nl> - : doc { _doc } , has_next { has_value } , error { SUCCESS } <nl> + simdjson_really_inline array : : array ( json_iterator * _iter , bool has_value ) noexcept <nl> + : iter { _iter } , has_next { has_value } , error { SUCCESS } <nl> { <nl> } <nl> simdjson_really_inline array : : array ( array & & other ) noexcept <nl> - : doc { other . doc } , has_next { other . has_next } , error { other . error } <nl> + : iter { other . iter } , has_next { other . has_next } , error { other . error } <nl> { <nl> / / Terminate the other iterator <nl> other . has_next = false ; <nl> } <nl> simdjson_really_inline array & array : : operator = ( array & & other ) noexcept { <nl> - doc = other . doc ; <nl> + iter = other . iter ; <nl> has_next = other . has_next ; <nl> error = other . error ; <nl> / / Terminate the other iterator <nl> simdjson_really_inline array & array : : operator = ( array & & other ) noexcept { <nl> <nl> simdjson_really_inline array : : ~ array ( ) noexcept { <nl> if ( ! error & & has_next ) { <nl> - logger : : log_event ( doc - > iter , " unfinished " , " array " ) ; <nl> - doc - > iter . skip_container ( ) ; <nl> + logger : : log_event ( * iter , " unfinished " , " array " ) ; <nl> + iter - > skip_container ( ) ; <nl> } <nl> } <nl> <nl> - simdjson_really_inline simdjson_result < array > array : : start ( document * doc ) noexcept { <nl> + simdjson_really_inline simdjson_result < array > array : : start ( json_iterator * iter ) noexcept { <nl> bool has_value ; <nl> - SIMDJSON_TRY ( doc - > iter . start_array ( ) . get ( has_value ) ) ; <nl> - return array ( doc , has_value ) ; <nl> + SIMDJSON_TRY ( iter - > start_array ( ) . get ( has_value ) ) ; <nl> + return array ( iter , has_value ) ; <nl> } <nl> - simdjson_really_inline array array : : started ( document * doc ) noexcept { <nl> - return array ( doc , doc - > iter . started_array ( ) ) ; <nl> + simdjson_really_inline array array : : started ( json_iterator * iter ) noexcept { <nl> + return array ( iter , iter - > started_array ( ) ) ; <nl> } <nl> simdjson_really_inline array : : iterator array : : begin ( ) noexcept { <nl> return * this ; <nl> simdjson_really_inline array : : iterator & array : : iterator : : operator = ( const array : : <nl> <nl> simdjson_really_inline simdjson_result < value > array : : iterator : : operator * ( ) noexcept { <nl> if ( a - > error ) { return a - > report_error ( ) ; } <nl> - return value : : start ( a - > doc ) ; <nl> + return value : : start ( a - > iter ) ; <nl> } <nl> simdjson_really_inline bool array : : iterator : : operator = = ( const array : : iterator & ) noexcept { <nl> return ! a - > has_next ; <nl> simdjson_really_inline bool array : : iterator : : operator ! = ( const array : : iterator & ) <nl> } <nl> simdjson_really_inline array : : iterator & array : : iterator : : operator + + ( ) noexcept { <nl> if ( a - > error ) { return * this ; } <nl> - a - > error = a - > doc - > iter . has_next_element ( ) . get ( a - > has_next ) ; / / If there ' s an error , has_next stays true . <nl> + a - > error = a - > iter - > has_next_element ( ) . get ( a - > has_next ) ; / / If there ' s an error , has_next stays true . <nl> return * this ; <nl> } <nl> <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : value > <nl> if ( error ( ) ) { return error ( ) ; } <nl> return * first ; <nl> } <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > : : operator = = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > & other ) noexcept { <nl> if ( error ( ) ) { return true ; } <nl> return first = = other . first ; <nl> } <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > : : operator ! = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > & other ) noexcept { <nl> if ( error ( ) ) { return false ; } <nl> return first ! = other . first ; <nl> mmm a / src / generic / ondemand / array . h <nl> ppp b / src / generic / ondemand / array . h <nl> class array { <nl> <nl> / / Reads key and value , yielding them to the user . <nl> simdjson_really_inline simdjson_result < value > operator * ( ) noexcept ; / / MUST ONLY BE CALLED ONCE PER ITERATION . <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool operator = = ( const array : : iterator & ) noexcept ; <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool operator ! = ( const array : : iterator & ) noexcept ; <nl> / / Checks for ' ] ' and ' , ' <nl> simdjson_really_inline array : : iterator & operator + + ( ) noexcept ; <nl> class array { <nl> * @ param doc The document containing the array . <nl> * @ error INCORRECT_TYPE if the iterator is not at [ . <nl> * / <nl> - static simdjson_really_inline simdjson_result < array > start ( document * doc ) noexcept ; <nl> + static simdjson_really_inline simdjson_result < array > start ( json_iterator * iter ) noexcept ; <nl> / * * <nl> * Begin array iteration . <nl> * <nl> * @ param doc The document containing the array . The iterator must be just after the opening ` [ ` . <nl> * / <nl> - static simdjson_really_inline array started ( document * doc ) noexcept ; <nl> + static simdjson_really_inline array started ( json_iterator * iter ) noexcept ; <nl> <nl> / * * <nl> * Report the current error and set finished so it won ' t be reported again . <nl> class array { <nl> / * * <nl> * Internal array creation . Call array : : start ( ) or array : : started ( ) instead of this . <nl> * <nl> - * @ param doc The document containing the array . doc - > iter . depth must already be incremented to <nl> + * @ param doc The document containing the array . iter - > depth must already be incremented to <nl> * reflect the array ' s depth . The iterator must be just after the opening ` [ ` . <nl> * @ param has_value Whether the array has a value ( false means empty array ) . <nl> * / <nl> - simdjson_really_inline array ( document * _doc , bool has_value ) noexcept ; <nl> + simdjson_really_inline array ( json_iterator * iter , bool has_value ) noexcept ; <nl> <nl> / * * <nl> * Document containing this array . <nl> class array { <nl> * PERF NOTE : expected to be elided in favor of the parent document : this is set when the array <nl> * is first used , and never changes afterwards . <nl> * / <nl> - document * doc { } ; <nl> + json_iterator * iter { } ; <nl> / * * <nl> * Whether we have anything to yield . <nl> * <nl> struct simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > : pub <nl> <nl> / / Reads key and value , yielding them to the user . <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : value > operator * ( ) noexcept ; / / MUST ONLY BE CALLED ONCE PER ITERATION . <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool operator = = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > & ) noexcept ; <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool operator ! = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > & ) noexcept ; <nl> / / Checks for ' ] ' and ' , ' <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : array : : iterator > & operator + + ( ) noexcept ; <nl> mmm a / src / generic / ondemand / document - inl . h <nl> ppp b / src / generic / ondemand / document - inl . h <nl> namespace { <nl> namespace SIMDJSON_IMPLEMENTATION { <nl> namespace ondemand { <nl> <nl> - simdjson_really_inline document : : document ( document & & other ) noexcept : <nl> - iter { std : : forward < json_iterator > ( other . iter ) } , <nl> - parser { other . parser } <nl> - { <nl> - if ( ! at_start ( ) ) { logger : : log_error ( iter , " Cannot move document after it has been used " ) ; abort ( ) ; } <nl> - other . parser = nullptr ; <nl> - } <nl> - simdjson_really_inline document & document : : operator = ( document & & other ) noexcept { <nl> - iter = std : : forward < json_iterator > ( other . iter ) ; <nl> - parser = other . parser ; <nl> - if ( ! at_start ( ) ) { logger : : log_error ( iter , " Cannot move document after it has been used " ) ; abort ( ) ; } <nl> - other . parser = nullptr ; <nl> - return * this ; <nl> - } <nl> - <nl> + simdjson_really_inline document : : document ( document & & other ) noexcept = default ; <nl> + simdjson_really_inline document & document : : operator = ( document & & other ) noexcept = default ; <nl> simdjson_really_inline document : : document ( ondemand : : parser * _parser ) noexcept <nl> - : iter ( _parser - > dom_parser . buf , _parser - > dom_parser . structural_indexes . get ( ) ) , parser { _parser } <nl> + : iter ( _parser ) <nl> { <nl> - logger : : log_headers ( ) ; <nl> - parser - > current_string_buf_loc = parser - > string_buf . get ( ) ; <nl> logger : : log_start_value ( iter , " document " ) ; <nl> } <nl> simdjson_really_inline document : : ~ document ( ) noexcept { <nl> - / / Release the string buf so it can be reused by the next document <nl> - if ( parser ) { <nl> + if ( iter . is_alive ( ) ) { <nl> logger : : log_end_value ( iter , " document " ) ; <nl> - parser - > current_string_buf_loc = nullptr ; <nl> } <nl> } <nl> <nl> simdjson_really_inline value document : : as_value ( ) noexcept { <nl> - if ( ! at_start ( ) ) { <nl> + if ( ! iter . at_start ( ) ) { <nl> logger : : log_error ( iter , " Document value can only be used once ! ondemand : : document is a forward - only input iterator . " ) ; <nl> abort ( ) ; / / TODO is there anything softer we can do ? I ' d rather not make this a simdjson_result just for user error . <nl> } <nl> - return value : : start ( this ) ; <nl> + return value : : start ( & iter ) ; <nl> } <nl> simdjson_really_inline json_iterator & document : : iterate ( ) & noexcept { <nl> - if ( ! at_start ( ) ) { <nl> + if ( ! iter . at_start ( ) ) { <nl> logger : : log_error ( iter , " Document value can only be used once ! ondemand : : document is a forward - only input iterator . " ) ; <nl> abort ( ) ; / / TODO is there anything softer we can do ? I ' d rather not make this a simdjson_result just for user error . <nl> } <nl> return iter ; <nl> } <nl> - simdjson_really_inline bool document : : at_start ( ) const noexcept { return iter . index = = parser - > dom_parser . structural_indexes . get ( ) ; } <nl> <nl> simdjson_really_inline simdjson_result < array > document : : get_array ( ) & noexcept { return as_value ( ) . get_array ( ) ; } <nl> simdjson_really_inline simdjson_result < object > document : : get_object ( ) & noexcept { return as_value ( ) . get_object ( ) ; } <nl> mmm a / src / generic / ondemand / document . h <nl> ppp b / src / generic / ondemand / document . h <nl> class document { <nl> simdjson_really_inline document ( ondemand : : parser * parser ) noexcept ; <nl> simdjson_really_inline const uint8_t * text ( uint32_t idx ) const noexcept ; <nl> <nl> - json_iterator iter ; / / / < Current position in the document <nl> - ondemand : : parser * parser ; <nl> + json_iterator iter { } ; / / / < Current position in the document <nl> <nl> simdjson_really_inline value as_value ( ) noexcept ; <nl> - simdjson_really_inline bool at_start ( ) const noexcept ; <nl> <nl> friend struct simdjson_result < document > ; <nl> friend class value ; <nl> mmm a / src / generic / ondemand / field - inl . h <nl> ppp b / src / generic / ondemand / field - inl . h <nl> simdjson_really_inline field : : field ( raw_json_string key , ondemand : : value & & value <nl> { <nl> } <nl> <nl> - simdjson_really_inline simdjson_result < field > field : : start ( document * doc ) noexcept { <nl> + simdjson_really_inline simdjson_result < field > field : : start ( json_iterator * iter ) noexcept { <nl> raw_json_string key ; <nl> - SIMDJSON_TRY ( doc - > iter . field_key ( ) . get ( key ) ) ; <nl> - SIMDJSON_TRY ( doc - > iter . field_value ( ) ) ; <nl> - return field : : start ( doc , key ) ; <nl> + SIMDJSON_TRY ( iter - > field_key ( ) . get ( key ) ) ; <nl> + SIMDJSON_TRY ( iter - > field_value ( ) ) ; <nl> + return field : : start ( iter , key ) ; <nl> } <nl> <nl> - simdjson_really_inline simdjson_result < field > field : : start ( document * doc , raw_json_string key ) noexcept { <nl> - return field ( key , value : : start ( doc ) ) ; <nl> + simdjson_really_inline simdjson_result < field > field : : start ( json_iterator * iter , raw_json_string key ) noexcept { <nl> + return field ( key , value : : start ( iter ) ) ; <nl> } <nl> <nl> simdjson_really_inline raw_json_string field : : key ( ) const noexcept { <nl> mmm a / src / generic / ondemand / field . h <nl> ppp b / src / generic / ondemand / field . h <nl> class field : public std : : pair < raw_json_string , value > { <nl> simdjson_really_inline ondemand : : value & value ( ) noexcept ; <nl> protected : <nl> simdjson_really_inline field ( raw_json_string key , ondemand : : value & & value ) noexcept ; <nl> - static simdjson_really_inline simdjson_result < field > start ( document * doc ) noexcept ; <nl> - static simdjson_really_inline simdjson_result < field > start ( document * doc , raw_json_string key ) noexcept ; <nl> + static simdjson_really_inline simdjson_result < field > start ( json_iterator * iter ) noexcept ; <nl> + static simdjson_really_inline simdjson_result < field > start ( json_iterator * iter , raw_json_string key ) noexcept ; <nl> friend struct simdjson_result < field > ; <nl> friend class object ; <nl> } ; <nl> mmm a / src / generic / ondemand / json_iterator - inl . h <nl> ppp b / src / generic / ondemand / json_iterator - inl . h <nl> namespace SIMDJSON_IMPLEMENTATION { <nl> namespace ondemand { <nl> <nl> simdjson_really_inline json_iterator : : json_iterator ( ) noexcept = default ; <nl> - simdjson_really_inline json_iterator : : json_iterator ( json_iterator & & other ) noexcept = default ; <nl> - simdjson_really_inline json_iterator & json_iterator : : operator = ( json_iterator & & other ) noexcept = default ; <nl> - simdjson_really_inline json_iterator : : json_iterator ( const uint8_t * _buf , uint32_t * _index ) noexcept <nl> - : token_iterator ( _buf , _index ) <nl> + simdjson_really_inline json_iterator : : json_iterator ( json_iterator & & other ) noexcept <nl> + : token_iterator ( std : : forward < token_iterator > ( other ) ) , <nl> + parser { other . parser } <nl> { <nl> + other . parser = nullptr ; <nl> + } <nl> + simdjson_really_inline json_iterator & json_iterator : : operator = ( json_iterator & & other ) noexcept { <nl> + buf = other . buf ; <nl> + index = other . index ; <nl> + parser = other . parser ; <nl> + other . parser = nullptr ; <nl> + return * this ; <nl> + } <nl> + simdjson_really_inline json_iterator : : json_iterator ( ondemand : : parser * _parser ) noexcept <nl> + : token_iterator ( _parser - > dom_parser . buf , _parser - > dom_parser . structural_indexes . get ( ) ) , parser { _parser } <nl> + { <nl> + / / Release the string buf so it can be reused by the next document <nl> + logger : : log_headers ( ) ; <nl> + parser - > current_string_buf_loc = parser - > string_buf . get ( ) ; <nl> + } <nl> + simdjson_really_inline json_iterator : : ~ json_iterator ( ) noexcept { <nl> + if ( parser ) { <nl> + parser - > current_string_buf_loc = nullptr ; <nl> + } <nl> } <nl> - <nl> <nl> SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result < bool > json_iterator : : start_object ( ) noexcept { <nl> if ( * advance ( ) ! = ' { ' ) { logger : : log_error ( * this , " Not an object " ) ; return INCORRECT_TYPE ; } <nl> simdjson_really_inline bool json_iterator : : skip_container ( ) noexcept { <nl> } ; <nl> } <nl> <nl> + simdjson_really_inline bool json_iterator : : at_start ( ) const noexcept { <nl> + return index = = parser - > dom_parser . structural_indexes . get ( ) ; <nl> + } <nl> + <nl> + simdjson_really_inline bool json_iterator : : at_eof ( ) const noexcept { <nl> + return index = = & parser - > dom_parser . structural_indexes [ parser - > dom_parser . n_structural_indexes ] ; <nl> + } <nl> + <nl> + simdjson_really_inline bool json_iterator : : is_alive ( ) const noexcept { <nl> + return parser ; <nl> + } <nl> + <nl> } / / namespace ondemand <nl> } / / namespace SIMDJSON_IMPLEMENTATION <nl> } / / namespace { <nl> mmm a / src / generic / ondemand / json_iterator . h <nl> ppp b / src / generic / ondemand / json_iterator . h <nl> class json_iterator : public token_iterator { <nl> simdjson_really_inline json_iterator & operator = ( json_iterator & & other ) noexcept ; <nl> simdjson_really_inline json_iterator ( const json_iterator & other ) noexcept = delete ; <nl> simdjson_really_inline json_iterator & operator = ( const json_iterator & other ) noexcept = delete ; <nl> + simdjson_really_inline ~ json_iterator ( ) noexcept ; <nl> <nl> / * * <nl> * Check for an opening { and start an object iteration . <nl> class json_iterator : public token_iterator { <nl> * / <nl> simdjson_really_inline bool skip_container ( ) noexcept ; <nl> <nl> + / * * <nl> + * Tell whether the iterator is still at the start <nl> + * / <nl> + simdjson_really_inline bool at_start ( ) const noexcept ; <nl> + <nl> + / * * <nl> + * Tell whether the iterator has reached EOF <nl> + * / <nl> + simdjson_really_inline bool at_eof ( ) const noexcept ; <nl> + <nl> + / * * <nl> + * Tell whether the iterator is live ( has not been moved ) . <nl> + * / <nl> + simdjson_really_inline bool is_alive ( ) const noexcept ; <nl> protected : <nl> - simdjson_really_inline json_iterator ( const uint8_t * buf , uint32_t * index ) noexcept ; <nl> + ondemand : : parser * parser { } ; <nl> + <nl> + simdjson_really_inline json_iterator ( ondemand : : parser * parser ) noexcept ; <nl> template < int N > <nl> SIMDJSON_WARN_UNUSED simdjson_really_inline bool advance_to_buffer ( uint8_t ( & buf ) [ N ] ) noexcept ; <nl> <nl> mmm a / src / generic / ondemand / object - inl . h <nl> ppp b / src / generic / ondemand / object - inl . h <nl> namespace ondemand { <nl> / / <nl> / / # # # Live States <nl> / / <nl> - / / While iterating or looking up values , depth > = doc - > iter . depth . at_start may vary . Error is <nl> + / / While iterating or looking up values , depth > = iter - > depth . at_start may vary . Error is <nl> / / always SUCCESS : <nl> / / <nl> / / - Start : This is the state when the object is first found and the iterator is just past the { . <nl> / / In this state , at_start = = true . <nl> / / - Next : After we hand a scalar value to the user , or an array / object which they then fully <nl> / / iterate over , the iterator is at the , or } before the next value . In this state , <nl> - / / depth = = doc - > iter . depth , at_start = = false , and error = = SUCCESS . <nl> + / / depth = = iter - > depth , at_start = = false , and error = = SUCCESS . <nl> / / - Unfinished Business : When we hand an array / object to the user which they do not fully <nl> / / iterate over , we need to finish that iteration by skipping child values until we reach the <nl> - / / Next state . In this state , depth > doc - > iter . depth , at_start = = false , and error = = SUCCESS . <nl> + / / Next state . In this state , depth > iter - > depth , at_start = = false , and error = = SUCCESS . <nl> / / <nl> / / # # Error States <nl> / / <nl> - / / In error states , we will yield exactly one more value before stopping . doc - > iter . depth = = depth <nl> + / / In error states , we will yield exactly one more value before stopping . iter - > depth = = depth <nl> / / and at_start is always false . We decrement after yielding the error , moving to the Finished <nl> / / state . <nl> / / <nl> / / - Chained Error : When the object iterator is part of an error chain - - for example , in <nl> / / ` for ( auto tweet : doc [ " tweets " ] ) ` , where the tweet field may be missing or not be an <nl> / / object - - we yield that error in the loop , exactly once . In this state , error ! = SUCCESS and <nl> - / / doc - > iter . depth = = depth , and at_start = = false . We decrement depth when we yield the error . <nl> + / / iter - > depth = = depth , and at_start = = false . We decrement depth when we yield the error . <nl> / / - Missing Comma Error : When the iterator + + method discovers there is no comma between fields , <nl> / / we flag that as an error and treat it exactly the same as a Chained Error . In this state , <nl> - / / error = = TAPE_ERROR , doc - > iter . depth = = depth , and at_start = = false . <nl> + / / error = = TAPE_ERROR , iter - > depth = = depth , and at_start = = false . <nl> / / <nl> / / Errors that occur while reading a field to give to the user ( such as when the key is not a <nl> / / string or the field is missing a colon ) are yielded immediately . Depth is then decremented , <nl> namespace ondemand { <nl> / / <nl> / / # # Terminal State <nl> / / <nl> - / / The terminal state has doc - > iter . depth < depth . at_start is always false . <nl> + / / The terminal state has iter - > depth < depth . at_start is always false . <nl> / / <nl> / / - Finished : When we have reached a } , we are finished . We signal this by decrementing depth . <nl> - / / In this state , doc - > iter . depth < depth , at_start = = false , and error = = SUCCESS . <nl> + / / In this state , iter - > depth < depth , at_start = = false , and error = = SUCCESS . <nl> / / <nl> <nl> simdjson_really_inline object : : object ( ) noexcept = default ; <nl> - simdjson_really_inline object : : object ( document * _doc , bool _has_value ) noexcept <nl> - : doc { _doc } , has_next { _has_value } , at_start { true } , error { SUCCESS } <nl> + simdjson_really_inline object : : object ( json_iterator * _iter , bool _has_value ) noexcept <nl> + : iter { _iter } , has_next { _has_value } , at_start { true } , error { SUCCESS } <nl> { <nl> } <nl> simdjson_really_inline object : : object ( object & & other ) noexcept <nl> - : doc { other . doc } , has_next { other . has_next } , at_start { other . at_start } , error { other . error } <nl> + : iter { other . iter } , has_next { other . has_next } , at_start { other . at_start } , error { other . error } <nl> { <nl> / / Terminate the other iterator <nl> other . has_next = false ; <nl> } <nl> simdjson_really_inline object & object : : operator = ( object & & other ) noexcept { <nl> - doc = other . doc ; <nl> + iter = other . iter ; <nl> has_next = other . has_next ; <nl> at_start = other . at_start ; <nl> error = other . error ; <nl> simdjson_really_inline object & object : : operator = ( object & & other ) noexcept { <nl> <nl> simdjson_really_inline object : : ~ object ( ) noexcept { <nl> if ( ! error & & has_next ) { <nl> - logger : : log_event ( doc - > iter , " unfinished " , " object " ) ; <nl> - doc - > iter . skip_container ( ) ; <nl> + logger : : log_event ( * iter , " unfinished " , " object " ) ; <nl> + iter - > skip_container ( ) ; <nl> } <nl> } <nl> <nl> simdjson_really_inline simdjson_result < value > object : : operator [ ] ( const std : : stri <nl> if ( at_start ) { <nl> at_start = false ; <nl> } else { <nl> - if ( ( error = doc - > iter . has_next_field ( ) . get ( has_next ) ) ) { return report_error ( ) ; } <nl> + if ( ( error = iter - > has_next_field ( ) . get ( has_next ) ) ) { return report_error ( ) ; } <nl> } <nl> } <nl> while ( has_next ) { <nl> / / Get the key <nl> raw_json_string actual_key ; <nl> - if ( ( error = doc - > iter . field_key ( ) . get ( actual_key ) ) ) { return report_error ( ) ; } ; <nl> - if ( ( error = doc - > iter . field_value ( ) ) ) { return report_error ( ) ; } <nl> + if ( ( error = iter - > field_key ( ) . get ( actual_key ) ) ) { return report_error ( ) ; } ; <nl> + if ( ( error = iter - > field_value ( ) ) ) { return report_error ( ) ; } <nl> <nl> / / Check if it matches <nl> if ( actual_key = = key ) { <nl> - logger : : log_event ( doc - > iter , " match " , key , - 2 ) ; <nl> - return value : : start ( doc ) ; <nl> + logger : : log_event ( * iter , " match " , key , - 2 ) ; <nl> + return value : : start ( iter ) ; <nl> } <nl> - logger : : log_event ( doc - > iter , " no match " , key , - 2 ) ; <nl> - doc - > iter . skip ( ) ; / / Skip the value entirely <nl> - if ( ( error = doc - > iter . has_next_field ( ) . get ( has_next ) ) ) { return report_error ( ) ; } <nl> + logger : : log_event ( * iter , " no match " , key , - 2 ) ; <nl> + iter - > skip ( ) ; / / Skip the value entirely <nl> + if ( ( error = iter - > has_next_field ( ) . get ( has_next ) ) ) { return report_error ( ) ; } <nl> } <nl> <nl> / / If the loop ended , we ' re out of fields to look at . <nl> return NO_SUCH_FIELD ; <nl> } <nl> <nl> - simdjson_really_inline simdjson_result < object > object : : start ( document * doc ) noexcept { <nl> + simdjson_really_inline simdjson_result < object > object : : start ( json_iterator * iter ) noexcept { <nl> bool has_value ; <nl> - SIMDJSON_TRY ( doc - > iter . start_object ( ) . get ( has_value ) ) ; <nl> - return object ( doc , has_value ) ; <nl> + SIMDJSON_TRY ( iter - > start_object ( ) . get ( has_value ) ) ; <nl> + return object ( iter , has_value ) ; <nl> } <nl> - simdjson_really_inline object object : : started ( document * doc ) noexcept { <nl> - return object ( doc , doc - > iter . started_object ( ) ) ; <nl> + simdjson_really_inline object object : : started ( json_iterator * iter ) noexcept { <nl> + return object ( iter , iter - > started_object ( ) ) ; <nl> } <nl> simdjson_really_inline object : : iterator object : : begin ( ) noexcept { <nl> return * this ; <nl> simdjson_really_inline object : : iterator & object : : iterator : : operator = ( const objec <nl> simdjson_really_inline simdjson_result < field > object : : iterator : : operator * ( ) noexcept { <nl> if ( o - > error ) { return o - > report_error ( ) ; } <nl> if ( o - > at_start ) { o - > at_start = false ; } <nl> - return field : : start ( o - > doc ) ; <nl> + return field : : start ( o - > iter ) ; <nl> } <nl> simdjson_really_inline bool object : : iterator : : operator = = ( const object : : iterator & ) noexcept { <nl> return ! o - > has_next ; <nl> simdjson_really_inline bool object : : iterator : : operator ! = ( const object : : iterator <nl> } <nl> simdjson_really_inline object : : iterator & object : : iterator : : operator + + ( ) noexcept { <nl> if ( o - > error ) { return * this ; } <nl> - o - > error = o - > doc - > iter . has_next_element ( ) . get ( o - > has_next ) ; / / If there ' s an error , has_next stays true . <nl> + o - > error = o - > iter - > has_next_element ( ) . get ( o - > has_next ) ; / / If there ' s an error , has_next stays true . <nl> return * this ; <nl> } <nl> <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : field > <nl> if ( error ( ) ) { return error ( ) ; } <nl> return * first ; <nl> } <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > : : operator = = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > & other ) noexcept { <nl> if ( error ( ) ) { return true ; } <nl> return first = = other . first ; <nl> } <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > : : operator ! = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > & other ) noexcept { <nl> if ( error ( ) ) { return false ; } <nl> return first ! = other . first ; <nl> mmm a / src / generic / ondemand / object . h <nl> ppp b / src / generic / ondemand / object . h <nl> class object { <nl> <nl> / / Reads key and value , yielding them to the user . <nl> simdjson_really_inline simdjson_result < field > operator * ( ) noexcept ; / / MUST ONLY BE CALLED ONCE PER ITERATION . <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool operator = = ( const object : : iterator & ) noexcept ; <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool operator ! = ( const object : : iterator & ) noexcept ; <nl> / / Checks for ' ] ' and ' , ' <nl> simdjson_really_inline object : : iterator & operator + + ( ) noexcept ; <nl> class object { <nl> * @ param doc The document containing the object . The iterator must be just after the opening ` { ` . <nl> * @ param error If this is not SUCCESS , creates an error chained object . <nl> * / <nl> - static simdjson_really_inline simdjson_result < object > start ( document * doc ) noexcept ; <nl> - static simdjson_really_inline object started ( document * doc ) noexcept ; <nl> + static simdjson_really_inline simdjson_result < object > start ( json_iterator * iter ) noexcept ; <nl> + static simdjson_really_inline object started ( json_iterator * iter ) noexcept ; <nl> <nl> / * * <nl> * Internal object creation . Call object : : begin ( doc ) instead of this . <nl> class object { <nl> * @ param is_empty Whether this container is empty or not . <nl> * @ param error The error to report . If the error is not SUCCESS , this is an error chained object . <nl> * / <nl> - simdjson_really_inline object ( document * _doc , bool is_empty ) noexcept ; <nl> + simdjson_really_inline object ( json_iterator * _iter , bool is_empty ) noexcept ; <nl> <nl> simdjson_really_inline error_code report_error ( ) noexcept ; <nl> <nl> class object { <nl> * PERF NOTE : expected to be elided in favor of the parent document : this is set when the object <nl> * is first used , and never changes afterwards . <nl> * / <nl> - document * doc { } ; <nl> + json_iterator * iter { } ; <nl> / * * <nl> * Whether we have anything to yield . <nl> * <nl> struct simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > : pu <nl> <nl> / / Reads key and value , yielding them to the user . <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : field > operator * ( ) noexcept ; / / MUST ONLY BE CALLED ONCE PER ITERATION . <nl> - / / Assumes it ' s being compared with the end . true if depth < doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth < iter - > depth . <nl> simdjson_really_inline bool operator = = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > & ) noexcept ; <nl> - / / Assumes it ' s being compared with the end . true if depth > = doc - > iter . depth . <nl> + / / Assumes it ' s being compared with the end . true if depth > = iter - > depth . <nl> simdjson_really_inline bool operator ! = ( const simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > & ) noexcept ; <nl> / / Checks for ' ] ' and ' , ' <nl> simdjson_really_inline simdjson_result < SIMDJSON_IMPLEMENTATION : : ondemand : : object : : iterator > & operator + + ( ) noexcept ; <nl> mmm a / src / generic / ondemand / parser . h <nl> ppp b / src / generic / ondemand / parser . h <nl> class parser { <nl> uint8_t * current_string_buf_loc { } ; <nl> <nl> friend class raw_json_string ; <nl> - friend class document ; <nl> friend class value ; <nl> + friend class json_iterator ; <nl> } ; <nl> <nl> } / / namespace ondemand <nl> mmm a / src / generic / ondemand / value - inl . h <nl> ppp b / src / generic / ondemand / value - inl . h <nl> simdjson_really_inline value : : value ( value & & other ) noexcept { <nl> * this = std : : forward < value > ( other ) ; <nl> } ; <nl> simdjson_really_inline value & value : : operator = ( value & & other ) noexcept { <nl> - doc = other . doc ; <nl> + iter = other . iter ; <nl> json = other . json ; <nl> other . json = nullptr ; <nl> return * this ; <nl> } <nl> - simdjson_really_inline value : : value ( document * _doc , const uint8_t * _json ) noexcept : doc { _doc } , json { _json } { <nl> - SIMDJSON_ASSUME ( doc ! = nullptr ) ; <nl> + simdjson_really_inline value : : value ( json_iterator * _iter , const uint8_t * _json ) noexcept : iter { _iter } , json { _json } { <nl> + SIMDJSON_ASSUME ( iter ! = nullptr ) ; <nl> SIMDJSON_ASSUME ( json ! = nullptr ) ; <nl> } <nl> <nl> simdjson_really_inline value : : ~ value ( ) noexcept { <nl> / / gets bumped on the error path unless that ' s costing us something important . <nl> if ( json ) { <nl> if ( * json = = ' [ ' | | * json = = ' { ' ) { <nl> - logger : : log_start_value ( doc - > iter , " unused " ) ; <nl> - doc - > iter . skip_container ( ) ; <nl> + logger : : log_start_value ( * iter , " unused " ) ; <nl> + iter - > skip_container ( ) ; <nl> } else { <nl> - logger : : log_value ( doc - > iter , " unused " ) ; <nl> + logger : : log_value ( * iter , " unused " ) ; <nl> } <nl> } <nl> } <nl> <nl> - simdjson_really_inline value value : : start ( document * doc ) noexcept { <nl> - return { doc , doc - > iter . advance ( ) } ; <nl> + simdjson_really_inline value value : : start ( json_iterator * iter ) noexcept { <nl> + return { iter , iter - > advance ( ) } ; <nl> } <nl> <nl> simdjson_really_inline simdjson_result < array > value : : get_array ( ) noexcept { <nl> simdjson_really_inline simdjson_result < array > value : : get_array ( ) noexcept { <nl> return INCORRECT_TYPE ; <nl> } <nl> json = nullptr ; / / Communicate that we have handled the value PERF TODO elided , right ? <nl> - return array : : started ( doc ) ; <nl> + return array : : started ( iter ) ; <nl> } <nl> simdjson_really_inline simdjson_result < object > value : : get_object ( ) noexcept { <nl> if ( * json ! = ' { ' ) { <nl> simdjson_really_inline simdjson_result < object > value : : get_object ( ) noexcept { <nl> return INCORRECT_TYPE ; <nl> } <nl> json = nullptr ; / / Communicate that we have handled the value PERF TODO elided , right ? <nl> - return object : : started ( doc ) ; <nl> + return object : : started ( iter ) ; <nl> } <nl> simdjson_really_inline simdjson_result < raw_json_string > value : : get_raw_json_string ( ) noexcept { <nl> log_value ( " string " ) ; <nl> simdjson_really_inline simdjson_result < std : : string_view > value : : get_string ( ) noe <nl> error_code error ; <nl> raw_json_string str ; <nl> if ( ( error = get_raw_json_string ( ) . get ( str ) ) ) { return error ; } <nl> - return str . unescape ( doc - > parser - > current_string_buf_loc ) ; <nl> + return str . unescape ( iter - > parser - > current_string_buf_loc ) ; <nl> } <nl> simdjson_really_inline simdjson_result < double > value : : get_double ( ) noexcept { <nl> log_value ( " double " ) ; <nl> simdjson_really_inline simdjson_result < value > value : : operator [ ] ( const char * key ) <nl> } <nl> <nl> simdjson_really_inline void value : : log_value ( const char * type ) const noexcept { <nl> - logger : : log_value ( doc - > iter , type ) ; <nl> + logger : : log_value ( * iter , type ) ; <nl> } <nl> simdjson_really_inline void value : : log_error ( const char * message ) const noexcept { <nl> - logger : : log_error ( doc - > iter , message ) ; <nl> + logger : : log_error ( * iter , message ) ; <nl> } <nl> <nl> } / / namespace ondemand <nl> mmm a / src / generic / ondemand / value . h <nl> ppp b / src / generic / ondemand / value . h <nl> class value { <nl> * <nl> * Use value : : read ( ) instead of this . <nl> * / <nl> - simdjson_really_inline value ( document * doc , const uint8_t * json ) noexcept ; <nl> + simdjson_really_inline value ( json_iterator * iter , const uint8_t * json ) noexcept ; <nl> <nl> / * * <nl> * Read a value . <nl> class value { <nl> * <nl> * @ param doc The document containing the value . Iterator must be at the value start position . <nl> * / <nl> - static simdjson_really_inline value start ( document * doc ) noexcept ; <nl> + static simdjson_really_inline value start ( json_iterator * iter ) noexcept ; <nl> <nl> simdjson_really_inline void log_value ( const char * type ) const noexcept ; <nl> simdjson_really_inline void log_error ( const char * message ) const noexcept ; <nl> <nl> - document * doc { } ; / / For the string buffer ( if we need it ) <nl> + json_iterator * iter { } ; / / For the string buffer ( if we need it ) <nl> const uint8_t * json { } ; / / The JSON text of the value <nl> <nl> friend class document ; <nl> | Use json_iterator as shared state instead of document | simdjson/simdjson | 3b53c6ca47d19bb2bfaf98a86f15c018bffee997 | 2020-10-04T19:47:29Z |
mmm a / include / grpcpp / impl / codegen / server_context . h <nl> ppp b / include / grpcpp / impl / codegen / server_context . h <nl> class ServerContextBase { <nl> / / / \ see grpc : : AuthContext . <nl> std : : shared_ptr < const : : grpc : : AuthContext > auth_context ( ) const { <nl> if ( auth_context_ . get ( ) = = nullptr ) { <nl> - auth_context_ = : : grpc : : CreateAuthContext ( call_ ) ; <nl> + auth_context_ = : : grpc : : CreateAuthContext ( call_ . call ) ; <nl> } <nl> return auth_context_ ; <nl> } <nl> class ServerContextBase { <nl> <nl> / / / Should be used for framework - level extensions only . <nl> / / / Applications never need to call this method . <nl> - grpc_call * c_call ( ) { return call_ ; } <nl> + grpc_call * c_call ( ) { return call_ . call ; } <nl> <nl> protected : <nl> / / / Async only . Has to be called before the rpc starts . <nl> class ServerContextBase { <nl> / / / Return the tag queued by BeginCompletionOp ( ) <nl> : : grpc : : internal : : CompletionQueueTag * GetCompletionOpTag ( ) ; <nl> <nl> - void set_call ( grpc_call * call ) { call_ = call ; } <nl> + void set_call ( grpc_call * call ) { call_ . call = call ; } <nl> <nl> void BindDeadlineAndMetadata ( gpr_timespec deadline , grpc_metadata_array * arr ) ; <nl> <nl> - void Clear ( ) ; <nl> - <nl> - void Setup ( gpr_timespec deadline ) ; <nl> - <nl> uint32_t initial_metadata_flags ( ) const { return 0 ; } <nl> <nl> : : grpc : : experimental : : ServerRpcInfo * set_server_rpc_info ( <nl> class ServerContextBase { <nl> message_allocator_state_ = allocator_state ; <nl> } <nl> <nl> - CompletionOp * completion_op_ ; <nl> - bool has_notify_when_done_tag_ ; <nl> - void * async_notify_when_done_tag_ ; <nl> + struct CallWrapper { <nl> + ~ CallWrapper ( ) ; <nl> + <nl> + grpc_call * call = nullptr ; <nl> + } ; <nl> + <nl> + / / NOTE : call_ must be the first data member of this object so that its <nl> + / / destructor is the last to be called , since its destructor may unref <nl> + / / the underlying core call which holds the arena that may be used to <nl> + / / hold this object . <nl> + CallWrapper call_ ; <nl> + <nl> + CompletionOp * completion_op_ = nullptr ; <nl> + bool has_notify_when_done_tag_ = false ; <nl> + void * async_notify_when_done_tag_ = nullptr ; <nl> : : grpc : : internal : : CallbackWithSuccessTag completion_tag_ ; <nl> <nl> gpr_timespec deadline_ ; <nl> - grpc_call * call_ ; <nl> - : : grpc : : CompletionQueue * cq_ ; <nl> - bool sent_initial_metadata_ ; <nl> + : : grpc : : CompletionQueue * cq_ = nullptr ; <nl> + bool sent_initial_metadata_ = false ; <nl> mutable std : : shared_ptr < const : : grpc : : AuthContext > auth_context_ ; <nl> mutable : : grpc : : internal : : MetadataMap client_metadata_ ; <nl> std : : multimap < std : : string , std : : string > initial_metadata_ ; <nl> std : : multimap < std : : string , std : : string > trailing_metadata_ ; <nl> <nl> - bool compression_level_set_ ; <nl> + bool compression_level_set_ = false ; <nl> grpc_compression_level compression_level_ ; <nl> grpc_compression_algorithm compression_algorithm_ ; <nl> <nl> : : grpc : : internal : : CallOpSet < : : grpc : : internal : : CallOpSendInitialMetadata , <nl> : : grpc : : internal : : CallOpSendMessage > <nl> pending_ops_ ; <nl> - bool has_pending_ops_ ; <nl> + bool has_pending_ops_ = false ; <nl> <nl> - : : grpc : : experimental : : ServerRpcInfo * rpc_info_ ; <nl> + : : grpc : : experimental : : ServerRpcInfo * rpc_info_ = nullptr ; <nl> : : grpc : : experimental : : RpcAllocatorState * message_allocator_state_ = nullptr ; <nl> <nl> class Reactor : public : : grpc : : ServerUnaryReactor { <nl> mmm a / src / cpp / client / client_context . cc <nl> ppp b / src / cpp / client / client_context . cc <nl> void ClientContext : : set_credentials ( <nl> std : : unique_ptr < ClientContext > ClientContext : : FromInternalServerContext ( <nl> const grpc : : ServerContextBase & context , PropagationOptions options ) { <nl> std : : unique_ptr < ClientContext > ctx ( new ClientContext ) ; <nl> - ctx - > propagate_from_call_ = context . call_ ; <nl> + ctx - > propagate_from_call_ = context . call_ . call ; <nl> ctx - > propagation_options_ = options ; <nl> return ctx ; <nl> } <nl> mmm a / src / cpp / server / server_context . cc <nl> ppp b / src / cpp / server / server_context . cc <nl> bool ServerContextBase : : CompletionOp : : FinalizeResult ( void * * tag , bool * status ) { <nl> <nl> / / ServerContextBase body <nl> <nl> - ServerContextBase : : ServerContextBase ( ) { <nl> - Setup ( gpr_inf_future ( GPR_CLOCK_REALTIME ) ) ; <nl> - } <nl> + ServerContextBase : : ServerContextBase ( ) <nl> + : deadline_ ( gpr_inf_future ( GPR_CLOCK_REALTIME ) ) { } <nl> <nl> ServerContextBase : : ServerContextBase ( gpr_timespec deadline , <nl> - grpc_metadata_array * arr ) { <nl> - Setup ( deadline ) ; <nl> + grpc_metadata_array * arr ) <nl> + : deadline_ ( deadline ) { <nl> std : : swap ( * client_metadata_ . arr ( ) , * arr ) ; <nl> } <nl> <nl> - void ServerContextBase : : Setup ( gpr_timespec deadline ) { <nl> - completion_op_ = nullptr ; <nl> - has_notify_when_done_tag_ = false ; <nl> - async_notify_when_done_tag_ = nullptr ; <nl> - deadline_ = deadline ; <nl> - call_ = nullptr ; <nl> - cq_ = nullptr ; <nl> - sent_initial_metadata_ = false ; <nl> - compression_level_set_ = false ; <nl> - has_pending_ops_ = false ; <nl> - rpc_info_ = nullptr ; <nl> - } <nl> - <nl> void ServerContextBase : : BindDeadlineAndMetadata ( gpr_timespec deadline , <nl> grpc_metadata_array * arr ) { <nl> deadline_ = deadline ; <nl> std : : swap ( * client_metadata_ . arr ( ) , * arr ) ; <nl> } <nl> <nl> - ServerContextBase : : ~ ServerContextBase ( ) { Clear ( ) ; } <nl> - <nl> - void ServerContextBase : : Clear ( ) { <nl> - auth_context_ . reset ( ) ; <nl> - initial_metadata_ . clear ( ) ; <nl> - trailing_metadata_ . clear ( ) ; <nl> - client_metadata_ . Reset ( ) ; <nl> + ServerContextBase : : ~ ServerContextBase ( ) { <nl> if ( completion_op_ ) { <nl> completion_op_ - > Unref ( ) ; <nl> - completion_op_ = nullptr ; <nl> - completion_tag_ . Clear ( ) ; <nl> } <nl> if ( rpc_info_ ) { <nl> rpc_info_ - > Unref ( ) ; <nl> - rpc_info_ = nullptr ; <nl> - } <nl> - if ( call_ ) { <nl> - auto * call = call_ ; <nl> - call_ = nullptr ; <nl> - grpc_call_unref ( call ) ; <nl> } <nl> if ( default_reactor_used_ . load ( std : : memory_order_relaxed ) ) { <nl> reinterpret_cast < Reactor * > ( & default_reactor_ ) - > ~ Reactor ( ) ; <nl> - default_reactor_used_ . store ( false , std : : memory_order_relaxed ) ; <nl> } <nl> - test_unary_ . reset ( ) ; <nl> + } <nl> + <nl> + ServerContextBase : : CallWrapper : : ~ CallWrapper ( ) { <nl> + if ( call ) { <nl> + / / If the ServerContext is part of the call ' s arena , this could free the <nl> + / / object itself . <nl> + grpc_call_unref ( call ) ; <nl> + } <nl> } <nl> <nl> void ServerContextBase : : BeginCompletionOp ( <nl> void ServerContextBase : : TryCancel ( ) const { <nl> rpc_info_ - > RunInterceptor ( & cancel_methods , i ) ; <nl> } <nl> } <nl> - grpc_call_error err = grpc_call_cancel_with_status ( <nl> - call_ , GRPC_STATUS_CANCELLED , " Cancelled on the server side " , nullptr ) ; <nl> + grpc_call_error err = <nl> + grpc_call_cancel_with_status ( call_ . call , GRPC_STATUS_CANCELLED , <nl> + " Cancelled on the server side " , nullptr ) ; <nl> if ( err ! = GRPC_CALL_OK ) { <nl> gpr_log ( GPR_ERROR , " TryCancel failed with : % d " , err ) ; <nl> } <nl> void ServerContextBase : : set_compression_algorithm ( <nl> <nl> std : : string ServerContextBase : : peer ( ) const { <nl> std : : string peer ; <nl> - if ( call_ ) { <nl> - char * c_peer = grpc_call_get_peer ( call_ ) ; <nl> + if ( call_ . call ) { <nl> + char * c_peer = grpc_call_get_peer ( call_ . call ) ; <nl> peer = c_peer ; <nl> gpr_free ( c_peer ) ; <nl> } <nl> std : : string ServerContextBase : : peer ( ) const { <nl> } <nl> <nl> const struct census_context * ServerContextBase : : census_context ( ) const { <nl> - return call_ = = nullptr ? nullptr : grpc_census_call_get_context ( call_ ) ; <nl> + return call_ . call = = nullptr ? nullptr <nl> + : grpc_census_call_get_context ( call_ . call ) ; <nl> } <nl> <nl> void ServerContextBase : : SetLoadReportingCosts ( <nl> const std : : vector < std : : string > & cost_data ) { <nl> - if ( call_ = = nullptr ) return ; <nl> + if ( call_ . call = = nullptr ) return ; <nl> for ( const auto & cost_datum : cost_data ) { <nl> AddTrailingMetadata ( GRPC_LB_COST_MD_KEY , cost_datum ) ; <nl> } <nl> mmm a / test / cpp / interop / server_helper . cc <nl> ppp b / test / cpp / interop / server_helper . cc <nl> InteropServerContextInspector : : InteropServerContextInspector ( <nl> <nl> grpc_compression_algorithm <nl> InteropServerContextInspector : : GetCallCompressionAlgorithm ( ) const { <nl> - return grpc_call_test_only_get_compression_algorithm ( context_ . call_ ) ; <nl> + return grpc_call_test_only_get_compression_algorithm ( context_ . call_ . call ) ; <nl> } <nl> <nl> uint32_t InteropServerContextInspector : : GetEncodingsAcceptedByClient ( ) const { <nl> - return grpc_call_test_only_get_encodings_accepted_by_peer ( context_ . call_ ) ; <nl> + return grpc_call_test_only_get_encodings_accepted_by_peer ( <nl> + context_ . call_ . call ) ; <nl> } <nl> <nl> bool InteropServerContextInspector : : WasCompressed ( ) const { <nl> - return ( grpc_call_test_only_get_message_flags ( context_ . call_ ) & <nl> + return ( grpc_call_test_only_get_message_flags ( context_ . call_ . call ) & <nl> GRPC_WRITE_INTERNAL_COMPRESS ) | | <nl> - ( grpc_call_test_only_get_message_flags ( context_ . call_ ) & <nl> + ( grpc_call_test_only_get_message_flags ( context_ . call_ . call ) & <nl> GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED ) ; <nl> } <nl> <nl> | Eliminate ServerContextBase : : Clear / Setup and fix unref process for core call | grpc/grpc | f8b046e81956985c76c774bae098b30458ae3c78 | 2020-09-22T07:37:25Z |
mmm a / Telegram / SourceFiles / media / streaming / media_streaming_utility . cpp <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_utility . cpp <nl> crl : : time PacketPosition ( const Packet & packet , AVRational timeBase ) { <nl> crl : : time FramePosition ( const Stream & stream ) { <nl> const auto pts = ! stream . frame <nl> ? AV_NOPTS_VALUE <nl> - : ( stream . frame - > pts = = AV_NOPTS_VALUE ) <nl> - ? stream . frame - > pkt_dts <nl> - : stream . frame - > pts ; <nl> + : ( stream . frame - > best_effort_timestamp ! = AV_NOPTS_VALUE ) <nl> + ? stream . frame - > best_effort_timestamp <nl> + : ( stream . frame - > pts ! = AV_NOPTS_VALUE ) <nl> + ? stream . frame - > pts <nl> + : stream . frame - > pkt_dts ; <nl> return PtsToTime ( pts , stream . timeBase ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_video_track . cpp <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_video_track . cpp <nl> namespace Streaming { <nl> namespace { <nl> <nl> constexpr auto kDisplaySkipped = crl : : time ( - 1 ) ; <nl> + constexpr auto kFinishedPosition = std : : numeric_limits < crl : : time > : : max ( ) ; <nl> static_assert ( kDisplaySkipped ! = kTimeUnknown ) ; <nl> <nl> } / / namespace <nl> class VideoTrackObject final { <nl> Looped , <nl> Finished , <nl> } ; <nl> + using ReadEnoughState = base : : optional_variant < <nl> + FrameResult , <nl> + Shared : : PrepareNextCheck > ; <nl> + <nl> [ [ nodiscard ] ] bool interrupted ( ) const ; <nl> [ [ nodiscard ] ] bool tryReadFirstFrame ( Packet & & packet ) ; <nl> [ [ nodiscard ] ] bool fillStateFromFrame ( ) ; <nl> [ [ nodiscard ] ] bool processFirstFrame ( ) ; <nl> void queueReadFrames ( crl : : time delay = 0 ) ; <nl> void readFrames ( ) ; <nl> + [ [ nodiscard ] ] ReadEnoughState readEnoughFrames ( crl : : time trackTime ) ; <nl> [ [ nodiscard ] ] FrameResult readFrame ( not_null < Frame * > frame ) ; <nl> void presentFrameIfNeeded ( ) ; <nl> void callReady ( ) ; <nl> void VideoTrackObject : : readFrames ( ) { <nl> return ; <nl> } <nl> auto time = trackTime ( ) . trackTime ; <nl> + while ( true ) { <nl> + const auto result = readEnoughFrames ( time ) ; <nl> + result . match ( [ & ] ( FrameResult result ) { <nl> + if ( result = = FrameResult : : Done <nl> + | | result = = FrameResult : : Finished ) { <nl> + presentFrameIfNeeded ( ) ; <nl> + } else if ( result = = FrameResult : : Looped ) { <nl> + time - = _stream . duration ; <nl> + } <nl> + } , [ & ] ( Shared : : PrepareNextCheck delay ) { <nl> + Expects ( delay = = kTimeUnknown | | delay > 0 ) ; <nl> + if ( delay ! = kTimeUnknown ) { <nl> + queueReadFrames ( delay ) ; <nl> + } <nl> + } , [ ] ( std : : nullopt_t ) { <nl> + } ) ; <nl> + if ( result . has_value ( ) ) { <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + auto VideoTrackObject : : readEnoughFrames ( crl : : time trackTime ) <nl> + - > ReadEnoughState { <nl> const auto dropStaleFrames = _options . dropStaleFrames ; <nl> - const auto state = _shared - > prepareState ( time , dropStaleFrames ) ; <nl> - state . match ( [ & ] ( Shared : : PrepareFrame frame ) { <nl> + const auto state = _shared - > prepareState ( trackTime , dropStaleFrames ) ; <nl> + return state . match ( [ & ] ( Shared : : PrepareFrame frame ) - > ReadEnoughState { <nl> while ( true ) { <nl> const auto result = readFrame ( frame ) ; <nl> - if ( result = = FrameResult : : Looped ) { <nl> - time - = _stream . duration ; <nl> - continue ; <nl> - } else if ( result ! = FrameResult : : Done ) { <nl> - break ; <nl> + if ( result ! = FrameResult : : Done ) { <nl> + return result ; <nl> } else if ( ! dropStaleFrames <nl> - | | ! VideoTrack : : IsStale ( frame , time ) ) { <nl> - LOG ( ( " READ FRAMES , TRACK TIME : % 1 " ) . arg ( time ) ) ; <nl> - presentFrameIfNeeded ( ) ; <nl> - break ; <nl> + | | ! VideoTrack : : IsStale ( frame , trackTime ) ) { <nl> + LOG ( ( " READ FRAMES , TRACK TIME : % 1 " ) . arg ( trackTime ) ) ; <nl> + return std : : nullopt ; <nl> } else { <nl> - LOG ( ( " DROPPED FRAMES , TRACK TIME : % 1 " ) . arg ( time ) ) ; <nl> + LOG ( ( " DROPPED FRAMES , TRACK TIME : % 1 " ) . arg ( trackTime ) ) ; <nl> } <nl> } <nl> - } , [ & ] ( Shared : : PrepareNextCheck delay ) { <nl> - Expects ( delay > 0 ) ; <nl> - <nl> - queueReadFrames ( delay ) ; <nl> - } , [ & ] ( std : : nullopt_t ) { <nl> - presentFrameIfNeeded ( ) ; <nl> + } , [ & ] ( Shared : : PrepareNextCheck delay ) - > ReadEnoughState { <nl> + return delay ; <nl> + } , [ & ] ( std : : nullopt_t ) - > ReadEnoughState { <nl> + return FrameResult : : Done ; <nl> } ) ; <nl> } <nl> <nl> auto VideoTrackObject : : readFrame ( not_null < Frame * > frame ) - > FrameResult { <nl> loopAround ( ) ; <nl> return FrameResult : : Looped ; <nl> } else { <nl> - interrupt ( ) ; <nl> - _nextFrameTimeUpdates = rpl : : event_stream < crl : : time > ( ) ; <nl> + frame - > position = kFinishedPosition ; <nl> + frame - > displayed = kTimeUnknown ; <nl> return FrameResult : : Finished ; <nl> } <nl> } else if ( error . code ( ) ! = AVERROR ( EAGAIN ) | | _noMoreData ) { <nl> void VideoTrackObject : : presentFrameIfNeeded ( ) { <nl> return ; <nl> } <nl> const auto time = trackTime ( ) ; <nl> - const auto prepare = [ & ] ( not_null < Frame * > frame ) { <nl> + const auto rasterize = [ & ] ( not_null < Frame * > frame ) { <nl> + Expects ( frame - > position ! = kFinishedPosition ) ; <nl> + <nl> frame - > request = _request ; <nl> frame - > original = ConvertFrame ( <nl> _stream , <nl> void VideoTrackObject : : presentFrameIfNeeded ( ) { <nl> <nl> VideoTrack : : PrepareFrameByRequest ( frame ) ; <nl> <nl> - Ensures ( VideoTrack : : IsPrepared ( frame ) ) ; <nl> + Ensures ( VideoTrack : : IsRasterized ( frame ) ) ; <nl> } ; <nl> - const auto presented = _shared - > presentFrame ( time . trackTime , prepare ) ; <nl> - if ( presented . displayPosition ! = kTimeUnknown ) { <nl> + const auto presented = _shared - > presentFrame ( <nl> + time . trackTime , <nl> + _options . dropStaleFrames , <nl> + rasterize ) ; <nl> + if ( presented . displayPosition = = kFinishedPosition ) { <nl> + interrupt ( ) ; <nl> + _nextFrameTimeUpdates = rpl : : event_stream < crl : : time > ( ) ; <nl> + return ; <nl> + } else if ( presented . displayPosition ! = kTimeUnknown ) { <nl> const auto trackLeft = presented . displayPosition - time . trackTime ; <nl> <nl> / / We don ' t use rpl : : variable , because we want an event each time <nl> void VideoTrackObject : : presentFrameIfNeeded ( ) { <nl> LOG ( ( " NOW : % 1 , FRAME POSITION : % 2 , TRACK TIME : % 3 , TRACK LEFT : % 4 , NEXT : % 5 " ) . arg ( time . worldTime ) . arg ( presented . displayPosition ) . arg ( time . trackTime ) . arg ( trackLeft ) . arg ( _nextFrameDisplayTime ) ) ; <nl> _nextFrameTimeUpdates . fire_copy ( _nextFrameDisplayTime ) ; <nl> } <nl> - queueReadFrames ( presented . nextCheckDelay ) ; <nl> + if ( presented . nextCheckDelay ! = kTimeUnknown ) { <nl> + Assert ( presented . nextCheckDelay > = 0 ) ; <nl> + queueReadFrames ( presented . nextCheckDelay ) ; <nl> + } <nl> } <nl> <nl> void VideoTrackObject : : pause ( crl : : time time ) { <nl> bool VideoTrackObject : : processFirstFrame ( ) { <nl> } <nl> <nl> crl : : time VideoTrackObject : : currentFramePosition ( ) const { <nl> - const auto position = _framePositionShift + std : : min ( <nl> - FramePosition ( _stream ) , <nl> - _stream . duration - 1 ) ; <nl> - if ( _previousFramePosition ! = kTimeUnknown <nl> - & & position < = _previousFramePosition ) { <nl> + const auto position = FramePosition ( _stream ) ; <nl> + LOG ( ( " FRAME_POSITION : % 1 ( pts : % 2 , dts : % 3 , duration : % 4 ) " <nl> + ) . arg ( position <nl> + ) . arg ( PtsToTime ( _stream . frame - > pts , _stream . timeBase ) <nl> + ) . arg ( PtsToTime ( _stream . frame - > pkt_dts , _stream . timeBase ) <nl> + ) . arg ( PtsToTime ( _stream . frame - > pkt_duration , _stream . timeBase ) ) ) ; <nl> + if ( position = = kTimeUnknown | | position = = kFinishedPosition ) { <nl> return kTimeUnknown ; <nl> } <nl> - _previousFramePosition = position ; <nl> - return position ; <nl> + return _framePositionShift + std : : clamp ( <nl> + position , <nl> + crl : : time ( 0 ) , <nl> + _stream . duration - 1 ) ; <nl> } <nl> <nl> bool VideoTrackObject : : fillStateFromFrame ( ) { <nl> auto VideoTrack : : Shared : : prepareState ( <nl> const auto next = getFrame ( ( index + 1 ) % kFramesCount ) ; <nl> if ( ! IsDecoded ( frame ) ) { <nl> return frame ; <nl> - } else if ( dropStaleFrames & & IsStale ( frame , trackTime ) ) { <nl> + } else if ( ! IsDecoded ( next ) ) { <nl> + return next ; <nl> + } else if ( next - > position < frame - > position ) { <nl> + LOG ( ( " INVALID ORDER , SWAPPING " ) ) ; <nl> + std : : swap ( * frame , * next ) ; <nl> + } <nl> + if ( next - > position = = kFinishedPosition | | ! dropStaleFrames ) { <nl> + return PrepareNextCheck ( kTimeUnknown ) ; <nl> + } else if ( IsStale ( frame , trackTime ) ) { <nl> std : : swap ( * frame , * next ) ; <nl> next - > displayed = kDisplaySkipped ; <nl> - return IsDecoded ( frame ) ? next : frame ; <nl> - } else if ( ! IsDecoded ( next ) ) { <nl> + LOG ( ( " DROPPED FRAMES , TRACK TIME : % 1 " ) . arg ( trackTime ) ) ; <nl> return next ; <nl> } else { <nl> return PrepareNextCheck ( frame - > position - trackTime + 1 ) ; <nl> } <nl> } ; <nl> - const auto finishPrepare = [ & ] ( int index ) { <nl> - const auto frame = getFrame ( index ) ; <nl> + const auto finishPrepare = [ & ] ( int index ) - > PrepareState { <nl> / / If player already awaits next frame - we ignore if it ' s stale . <nl> - return IsDecoded ( frame ) ? std : : nullopt : PrepareState ( frame ) ; <nl> + dropStaleFrames = false ; <nl> + const auto result = prepareNext ( index ) ; <nl> + return result . is < PrepareNextCheck > ( ) ? PrepareState ( ) : result ; <nl> } ; <nl> <nl> switch ( counter ( ) ) { <nl> auto VideoTrack : : Shared : : prepareState ( <nl> Unexpected ( " Counter value in VideoTrack : : Shared : : prepareState . " ) ; <nl> } <nl> <nl> - template < typename PrepareCallback > <nl> + template < typename RasterizeCallback > <nl> auto VideoTrack : : Shared : : presentFrame ( <nl> crl : : time trackTime , <nl> - PrepareCallback & & prepare ) <nl> + bool dropStaleFrames , <nl> + RasterizeCallback & & rasterize ) <nl> - > PresentFrame { <nl> const auto present = [ & ] ( int counter , int index ) - > PresentFrame { <nl> const auto frame = getFrame ( index ) ; <nl> const auto position = frame - > position ; <nl> - prepare ( frame ) ; <nl> - if ( ! IsPrepared ( frame ) ) { <nl> - return { kTimeUnknown , crl : : time ( 0 ) } ; <nl> + if ( position = = kFinishedPosition ) { <nl> + return { kFinishedPosition , kTimeUnknown } ; <nl> + } <nl> + rasterize ( frame ) ; <nl> + if ( ! IsRasterized ( frame ) ) { <nl> + / / Error happened during frame prepare . <nl> + return { kTimeUnknown , kTimeUnknown } ; <nl> } <nl> <nl> / / Release this frame to the main thread for rendering . <nl> auto VideoTrack : : Shared : : presentFrame ( <nl> } ; <nl> const auto nextCheckDelay = [ & ] ( int index ) - > PresentFrame { <nl> const auto frame = getFrame ( index ) ; <nl> + if ( frame - > position = = kFinishedPosition ) { <nl> + return { kFinishedPosition , kTimeUnknown } ; <nl> + } <nl> const auto next = getFrame ( ( index + 1 ) % kFramesCount ) ; <nl> - if ( ! IsDecoded ( frame ) <nl> - | | ! IsDecoded ( next ) <nl> - | | IsStale ( frame , trackTime ) ) { <nl> + if ( ! IsDecoded ( frame ) | | ! IsDecoded ( next ) ) { <nl> return { kTimeUnknown , crl : : time ( 0 ) } ; <nl> + } else if ( next - > position = = kFinishedPosition <nl> + | | ! dropStaleFrames <nl> + | | IsStale ( frame , trackTime ) ) { <nl> + return { kTimeUnknown , kTimeUnknown } ; <nl> } <nl> - return { kTimeUnknown , ( trackTime - frame - > position + 1 ) } ; <nl> + return { kTimeUnknown , ( frame - > position - trackTime + 1 ) } ; <nl> } ; <nl> <nl> LOG ( ( " PRESENT COUNTER : % 1 " ) . arg ( counter ( ) ) ) ; <nl> bool VideoTrack : : IsDecoded ( not_null < Frame * > frame ) { <nl> & & ( frame - > displayed = = kTimeUnknown ) ; <nl> } <nl> <nl> - bool VideoTrack : : IsPrepared ( not_null < Frame * > frame ) { <nl> + bool VideoTrack : : IsRasterized ( not_null < Frame * > frame ) { <nl> return IsDecoded ( frame ) <nl> & & ! frame - > original . isNull ( ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_video_track . h <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_video_track . h <nl> class VideoTrack final { <nl> crl : : time trackTime , <nl> bool dropStaleFrames ) ; <nl> <nl> - / / PrepareCallback ( not_null < Frame * > ) . <nl> - template < typename PrepareCallback > <nl> + / / RasterizeCallback ( not_null < Frame * > ) . <nl> + template < typename RasterizeCallback > <nl> [ [ nodiscard ] ] PresentFrame presentFrame ( <nl> crl : : time trackTime , <nl> - PrepareCallback & & prepare ) ; <nl> + bool dropStaleFrames , <nl> + RasterizeCallback & & rasterize ) ; <nl> <nl> / / Called from the main thread . <nl> / / Returns the position of the displayed frame . <nl> class VideoTrack final { <nl> not_null < Frame * > frame , <nl> bool useExistingPrepared = false ) ; <nl> [ [ nodiscard ] ] static bool IsDecoded ( not_null < Frame * > frame ) ; <nl> - [ [ nodiscard ] ] static bool IsPrepared ( not_null < Frame * > frame ) ; <nl> + [ [ nodiscard ] ] static bool IsRasterized ( not_null < Frame * > frame ) ; <nl> [ [ nodiscard ] ] static bool IsStale ( <nl> not_null < Frame * > frame , <nl> crl : : time trackTime ) ; <nl> | Improve video frame position checks . | telegramdesktop/tdesktop | 67b9fe846b80f1fdd2f523252e75b798e1c1387f | 2019-03-11T08:08:16Z |
mmm a / js / server / modules / org / arangodb / foxx / swagger . js <nl> ppp b / js / server / modules / org / arangodb / foxx / swagger . js <nl> <nl> - / * global ArangoServerState * / <nl> ' use strict ' ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function swaggerPath ( path , basePath ) { <nl> return path ; <nl> } <nl> if ( ! basePath ) { <nl> - basePath = fs . safeJoin ( ArangoServerState . javaScriptPath ( ) , ' server / assets / swagger ' ) ; <nl> + basePath = fs . join ( module . startupPath ( ) , ' server ' , ' assets ' , ' swagger ' ) ; <nl> } <nl> return fs . safeJoin ( basePath , path ) ; <nl> } <nl> mmm a / js / server / modules / org / arangodb / foxx / templateEngine . js <nl> ppp b / js / server / modules / org / arangodb / foxx / templateEngine . js <nl> <nl> + ' use strict ' ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Foxx template engine <nl> <nl> / / / <nl> / / / @ author Lucas Dohmen <nl> / / / @ author Michael Hackstein <nl> + / / / @ author Alan Plum <nl> / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - ( function ( ) { <nl> - ' use strict ' ; <nl> - <nl> - var fs = require ( " fs " ) , <nl> - _ = require ( " underscore " ) , <nl> - i = require ( ' i ' ) ( ) , <nl> - templatePath = fs . join ( <nl> - module . startupPath ( ) , <nl> - " server " , <nl> - " modules " , <nl> - " org " , <nl> - " arangodb " , <nl> - " foxx " , <nl> - " templates " <nl> - ) , <nl> - Engine ; <nl> - <nl> - Engine = function ( opts ) { <nl> - this . _path = templatePath ; <nl> - this . folder = opts . path ; <nl> - this . name = opts . name ; <nl> - this . authenticated = opts . authenticated ; <nl> - this . author = opts . author ; <nl> - this . description = opts . description ; <nl> - this . license = opts . license ; <nl> - this . determineFromCollectionNames ( opts . collectionNames ) ; <nl> - } ; <nl> - <nl> - _ . extend ( Engine . prototype , { <nl> - write : function ( ) { <nl> - fs . makeDirectory ( this . folder ) ; <nl> - fs . makeDirectory ( fs . join ( this . folder , ' controllers ' ) ) ; <nl> - fs . makeDirectory ( fs . join ( this . folder , ' models ' ) ) ; <nl> - fs . makeDirectory ( fs . join ( this . folder , ' repositories ' ) ) ; <nl> - fs . makeDirectory ( fs . join ( this . folder , ' scripts ' ) ) ; <nl> - fs . makeDirectory ( fs . join ( this . folder , ' test ' ) ) ; <nl> - fs . write ( fs . join ( this . folder , ' manifest . json ' ) , this . buildManifest ( ) ) ; <nl> - <nl> - _ . each ( this . repositories , function ( repository ) { <nl> - fs . write ( fs . join ( this . folder , repository . path ) , this . buildRepository ( ) ) ; <nl> - } , this ) ; <nl> - <nl> - _ . each ( this . models , function ( model ) { <nl> - fs . write ( fs . join ( this . folder , model . path ) , this . buildModel ( ) ) ; <nl> - } , this ) ; <nl> - <nl> - _ . each ( this . controllers , function ( controller ) { <nl> - fs . write ( fs . join ( this . folder , controller . path ) , this . buildController ( controller ) ) ; <nl> - } , this ) ; <nl> - <nl> - fs . write ( fs . join ( this . folder , " scripts " , " setup . js " ) , this . buildSetup ( this . collectionNames ) ) ; <nl> - <nl> - fs . write ( fs . join ( this . folder , " scripts " , " teardown . js " ) , this . buildTeardown ( this . collectionNames ) ) ; <nl> - <nl> - fs . write ( fs . join ( this . folder , " test " , " example . js " ) , this . buildTest ( ) ) ; <nl> - } , <nl> - <nl> - template : function ( name ) { <nl> - return _ . template ( fs . read ( fs . join ( this . _path , name ) ) ) ; <nl> - } , <nl> - <nl> - determineFromCollectionNames : function ( collectionNames ) { <nl> - this . collectionNames = [ ] ; <nl> - this . controllers = [ ] ; <nl> - this . repositories = [ ] ; <nl> - this . models = [ ] ; <nl> - <nl> - _ . each ( collectionNames , function ( collectionName ) { <nl> - var modelBase = i . singularize ( collectionName ) . substr ( 1 ) , <nl> - collectionStart , <nl> - repositoryBase = collectionName . substr ( 1 ) , <nl> - repositoryName , <nl> - repositoryPath , <nl> - repositoryInstance , <nl> - modelPath , <nl> - modelName , <nl> - modelInstance ; <nl> - collectionStart = collectionName . charAt ( 0 ) ; <nl> - if ( collectionStart . match ( " [ a - zA - Z ] " ) = = = null ) { <nl> - throw " Collection Name has to start with a letter " ; <nl> - } <nl> - if ( modelBase = = = repositoryBase ) { <nl> - repositoryBase + = " Repo " ; <nl> - } <nl> - modelName = collectionStart . toUpperCase ( ) + modelBase ; <nl> - modelInstance = collectionStart . toLowerCase ( ) + modelBase ; <nl> - repositoryName = collectionStart . toUpperCase ( ) + repositoryBase ; <nl> - repositoryInstance = collectionStart . toLowerCase ( ) + repositoryBase ; <nl> - repositoryPath = ' repositories / ' + collectionName ; <nl> - modelPath = ' models / ' + modelName . toLowerCase ( ) ; <nl> - <nl> - this . collectionNames . push ( collectionName ) ; <nl> - this . controllers . push ( { <nl> - url : ' / ' + collectionName , <nl> - path : ' controllers / ' + collectionName + ' . js ' , <nl> - repositoryInstance : repositoryInstance , <nl> - repository : repositoryName , <nl> - repositoryPath : repositoryPath , <nl> - modelInstance : modelInstance , <nl> - model : modelName , <nl> - modelPath : modelPath , <nl> - basePath : collectionName , <nl> - collectionName : collectionName <nl> - } ) ; <nl> - this . repositories . push ( { <nl> - path : repositoryPath + ' . js ' <nl> - } ) ; <nl> - this . models . push ( { <nl> - path : modelPath + ' . js ' <nl> - } ) ; <nl> - } , this ) ; <nl> - } , <nl> - <nl> - buildManifest : function ( ) { <nl> - var manifest = { <nl> - name : this . name , <nl> - description : this . description , <nl> - author : this . author , <nl> - version : ' 0 . 0 . 1 ' , <nl> - license : this . license , <nl> - controllers : { } , <nl> - scripts : { <nl> - setup : " scripts / setup . js " , <nl> - teardown : " scripts / teardown . js " <nl> - } , <nl> - tests : " test / * * / * . js " <nl> - } ; <nl> - <nl> - _ . each ( this . controllers , function ( controller ) { <nl> - manifest . controllers [ controller . url ] = controller . path ; <nl> + var _ = require ( ' underscore ' ) ; <nl> + var fs = require ( ' fs ' ) ; <nl> + var i = require ( ' i ' ) ( ) ; <nl> + var templatePath = fs . join ( <nl> + module . startupPath ( ) , <nl> + ' server ' , <nl> + ' modules ' , <nl> + ' org ' , <nl> + ' arangodb ' , <nl> + ' foxx ' , <nl> + ' templates ' <nl> + ) ; <nl> + <nl> + function Engine ( opts ) { <nl> + this . _path = templatePath ; <nl> + this . folder = opts . path ; <nl> + this . name = opts . name ; <nl> + this . authenticated = opts . authenticated ; <nl> + this . author = opts . author ; <nl> + this . description = opts . description ; <nl> + this . license = opts . license ; <nl> + this . determineFromCollectionNames ( opts . collectionNames ) ; <nl> + } <nl> + <nl> + _ . extend ( Engine . prototype , { <nl> + write : function ( ) { <nl> + fs . makeDirectory ( this . folder ) ; <nl> + fs . makeDirectory ( fs . join ( this . folder , ' controllers ' ) ) ; <nl> + fs . makeDirectory ( fs . join ( this . folder , ' models ' ) ) ; <nl> + fs . makeDirectory ( fs . join ( this . folder , ' repositories ' ) ) ; <nl> + fs . makeDirectory ( fs . join ( this . folder , ' scripts ' ) ) ; <nl> + fs . makeDirectory ( fs . join ( this . folder , ' test ' ) ) ; <nl> + fs . write ( fs . join ( this . folder , ' manifest . json ' ) , this . buildManifest ( ) ) ; <nl> + <nl> + _ . each ( this . repositories , function ( repository ) { <nl> + fs . write ( fs . join ( this . folder , repository . path ) , this . buildRepository ( ) ) ; <nl> + } , this ) ; <nl> + <nl> + _ . each ( this . models , function ( model ) { <nl> + fs . write ( fs . join ( this . folder , model . path ) , this . buildModel ( ) ) ; <nl> + } , this ) ; <nl> + <nl> + _ . each ( this . controllers , function ( controller ) { <nl> + fs . write ( fs . join ( this . folder , controller . path ) , this . buildController ( controller ) ) ; <nl> + } , this ) ; <nl> + <nl> + fs . write ( fs . join ( this . folder , ' scripts ' , ' setup . js ' ) , this . buildSetup ( this . collectionNames ) ) ; <nl> + fs . write ( fs . join ( this . folder , ' scripts ' , ' teardown . js ' ) , this . buildTeardown ( this . collectionNames ) ) ; <nl> + fs . write ( fs . join ( this . folder , ' test ' , ' example . js ' ) , this . buildTest ( ) ) ; <nl> + } , <nl> + <nl> + template : function ( name ) { <nl> + return _ . template ( fs . read ( fs . join ( this . _path , name ) ) ) ; <nl> + } , <nl> + <nl> + determineFromCollectionNames : function ( collectionNames ) { <nl> + this . collectionNames = [ ] ; <nl> + this . controllers = [ ] ; <nl> + this . repositories = [ ] ; <nl> + this . models = [ ] ; <nl> + <nl> + _ . each ( collectionNames , function ( collectionName ) { <nl> + var modelBase = i . singularize ( collectionName ) . substr ( 1 ) , <nl> + collectionStart , <nl> + repositoryBase = collectionName . substr ( 1 ) , <nl> + repositoryName , <nl> + repositoryPath , <nl> + repositoryInstance , <nl> + modelPath , <nl> + modelName , <nl> + modelInstance ; <nl> + collectionStart = collectionName . charAt ( 0 ) ; <nl> + if ( collectionStart . match ( / [ a - z ] / i ) = = = null ) { <nl> + throw new Error ( ' Collection name has to start with a letter ' ) ; <nl> + } <nl> + if ( modelBase = = = repositoryBase ) { <nl> + repositoryBase + = ' Repo ' ; <nl> + } <nl> + modelName = collectionStart . toUpperCase ( ) + modelBase ; <nl> + modelInstance = collectionStart . toLowerCase ( ) + modelBase ; <nl> + repositoryName = collectionStart . toUpperCase ( ) + repositoryBase ; <nl> + repositoryInstance = collectionStart . toLowerCase ( ) + repositoryBase ; <nl> + repositoryPath = ' repositories / ' + collectionName ; <nl> + modelPath = ' models / ' + modelName . toLowerCase ( ) ; <nl> + <nl> + this . collectionNames . push ( collectionName ) ; <nl> + this . controllers . push ( { <nl> + url : ' / ' + collectionName , <nl> + path : ' controllers / ' + collectionName + ' . js ' , <nl> + repositoryInstance : repositoryInstance , <nl> + repository : repositoryName , <nl> + repositoryPath : repositoryPath , <nl> + modelInstance : modelInstance , <nl> + model : modelName , <nl> + modelPath : modelPath , <nl> + basePath : collectionName , <nl> + collectionName : collectionName <nl> } ) ; <nl> + this . repositories . push ( { <nl> + path : repositoryPath + ' . js ' <nl> + } ) ; <nl> + this . models . push ( { <nl> + path : modelPath + ' . js ' <nl> + } ) ; <nl> + } , this ) ; <nl> + } , <nl> <nl> - return JSON . stringify ( manifest , 0 , 2 ) ; <nl> - } , <nl> + buildManifest : function ( ) { <nl> + var manifest = { <nl> + name : this . name , <nl> + description : this . description , <nl> + author : this . author , <nl> + version : ' 0 . 0 . 1 ' , <nl> + license : this . license , <nl> + controllers : { } , <nl> + scripts : { <nl> + setup : ' scripts / setup . js ' , <nl> + teardown : ' scripts / teardown . js ' <nl> + } , <nl> + tests : ' test / * * / * . js ' <nl> + } ; <nl> <nl> + _ . each ( this . controllers , function ( controller ) { <nl> + manifest . controllers [ controller . url ] = controller . path ; <nl> + } ) ; <nl> <nl> - buildSetup : function ( collections ) { <nl> - var templ = this . template ( " setup . js . tmpl " ) ; <nl> + return JSON . stringify ( manifest , 0 , 2 ) ; <nl> + } , <nl> <nl> - return templ ( { <nl> - collections : collections <nl> - } ) ; <nl> - } , <nl> <nl> - buildTeardown : function ( collections ) { <nl> - var templ = this . template ( " teardown . js . tmpl " ) ; <nl> + buildSetup : function ( collections ) { <nl> + var templ = this . template ( ' setup . js . tmpl ' ) ; <nl> <nl> - return templ ( { <nl> - collections : collections <nl> - } ) ; <nl> - } , <nl> + return templ ( { <nl> + collections : collections <nl> + } ) ; <nl> + } , <nl> + <nl> + buildTeardown : function ( collections ) { <nl> + var templ = this . template ( ' teardown . js . tmpl ' ) ; <nl> + <nl> + return templ ( { <nl> + collections : collections <nl> + } ) ; <nl> + } , <nl> <nl> - buildController : function ( controller ) { <nl> - var templ = this . template ( " controller . js . tmpl " ) ; <nl> + buildController : function ( controller ) { <nl> + var templ = this . template ( ' controller . js . tmpl ' ) ; <nl> <nl> - return templ ( controller ) ; <nl> - } , <nl> + return templ ( controller ) ; <nl> + } , <nl> <nl> <nl> - buildRepository : function ( ) { <nl> - var templ = this . template ( " repository . js . tmpl " ) ; <nl> + buildRepository : function ( ) { <nl> + var templ = this . template ( ' repository . js . tmpl ' ) ; <nl> <nl> - return templ ( ) ; <nl> - } , <nl> + return templ ( ) ; <nl> + } , <nl> <nl> - buildModel : function ( ) { <nl> - var templ = this . template ( " model . js . tmpl " ) ; <nl> + buildModel : function ( ) { <nl> + var templ = this . template ( ' model . js . tmpl ' ) ; <nl> <nl> - return templ ( ) ; <nl> - } , <nl> + return templ ( ) ; <nl> + } , <nl> <nl> - buildTest : function ( ) { <nl> - var templ = this . template ( " test . js . tmpl " ) ; <nl> + buildTest : function ( ) { <nl> + var templ = this . template ( ' test . js . tmpl ' ) ; <nl> <nl> - return templ ( ) ; <nl> - } <nl> - } ) ; <nl> + return templ ( ) ; <nl> + } <nl> + } ) ; <nl> <nl> - exports . Engine = Engine ; <nl> - } ( ) ) ; <nl> + exports . Engine = Engine ; <nl> | Code style . | arangodb/arangodb | de9d102f9b2affd360b01569934effa504874e74 | 2015-05-07T18:38:18Z |
mmm a / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / src / Storages / StorageReplicatedMergeTree . cpp <nl> static std : : string normalizeZooKeeperPath ( std : : string zookeeper_path ) <nl> return zookeeper_path ; <nl> } <nl> <nl> - void StorageReplicatedMergeTree : : extractZooKeeperNameAndPath ( const String & path , String & zookeeper_name_ , String & zookeeper_path_ ) const <nl> + void StorageReplicatedMergeTree : : extractZooKeeperNameAndPath ( const String & path , String & zookeeper_name_ , String & zookeeper_path_ ) <nl> { <nl> if ( path . empty ( ) ) <nl> throw Exception ( " ZooKeeper path should not be empty " , ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> mmm a / src / Storages / StorageReplicatedMergeTree . h <nl> ppp b / src / Storages / StorageReplicatedMergeTree . h <nl> class StorageReplicatedMergeTree final : public ext : : shared_ptr_helper < StorageRe <nl> zkutil : : ZooKeeperPtr tryGetZooKeeper ( ) const ; <nl> zkutil : : ZooKeeperPtr getZooKeeper ( ) const ; <nl> void setZooKeeper ( ) ; <nl> - void extractZooKeeperNameAndPath ( const String & path , String & zookeeper_name_ , String & zookeeper_path_ ) const ; <nl> + static void extractZooKeeperNameAndPath ( const String & path , String & zookeeper_name_ , String & zookeeper_path_ ) ; <nl> <nl> / / / If true , the table is offline and can not be written to it . <nl> std : : atomic_bool is_readonly { false } ; <nl> | fix build | ClickHouse/ClickHouse | 091f7065cd7e6beec6a6615895ebf92f6d2d061a | 2020-11-19T07:44:47Z |
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> <nl> - cmake_minimum_required ( VERSION 2 . 8 . 7 ) <nl> + cmake_minimum_required ( VERSION 2 . 8 . 7 ) <nl> <nl> project ( mxnet C CXX ) <nl> <nl> if ( USE_OPENCV ) <nl> endif ( ) <nl> <nl> if ( USE_OPENMP ) <nl> - FIND_PACKAGE ( OpenMP REQUIRED ) <nl> - if ( OPENMP_FOUND ) <nl> - set ( CMAKE_C_FLAGS " $ { CMAKE_C_FLAGS } $ { OpenMP_C_FLAGS } " ) <nl> - set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } $ { OpenMP_CXX_FLAGS } " ) <nl> - set ( CMAKE_SHARED_LINKER_FLAGS " $ { CMAKE_SHARED_LINKER_FLAGS } $ { OpenMP_EXE_LINKER_FLAGS } " ) <nl> - set ( CMAKE_EXE_LINKER_FLAGS " $ { CMAKE_EXE_LINKER_FLAGS } $ { OpenMP_EXE_LINKER_FLAGS } " ) <nl> - endif ( ) <nl> + FIND_PACKAGE ( OpenMP REQUIRED ) <nl> + if ( OPENMP_FOUND ) <nl> + set ( CMAKE_C_FLAGS " $ { CMAKE_C_FLAGS } $ { OpenMP_C_FLAGS } " ) <nl> + set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } $ { OpenMP_CXX_FLAGS } " ) <nl> + set ( CMAKE_SHARED_LINKER_FLAGS " $ { CMAKE_SHARED_LINKER_FLAGS } $ { OpenMP_EXE_LINKER_FLAGS } " ) <nl> + set ( CMAKE_EXE_LINKER_FLAGS " $ { CMAKE_EXE_LINKER_FLAGS } $ { OpenMP_EXE_LINKER_FLAGS } " ) <nl> + endif ( ) <nl> endif ( ) <nl> <nl> # cudnn detection <nl> if ( NOT MSVC ) <nl> # Only add c + + 11 flags and definitions after cuda compiling <nl> add_definitions ( - DDMLC_USE_CXX11 ) <nl> add_definitions ( - DMSHADOW_IN_CXX11 ) <nl> - set ( CMAKE_C_FLAGS " $ { CMAKE_C_FLAGS } - std = c + + 0x " ) <nl> - set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - std = c + + 0x " ) <nl> + set ( CMAKE_C_FLAGS " $ { CMAKE_C_FLAGS } - std = c + + 0x " ) <nl> + set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - std = c + + 0x " ) <nl> endif ( ) <nl> <nl> - add_library ( mxnet SHARED $ { SOURCE } ) <nl> + add_library ( mxnet SHARED $ { SOURCE } ) <nl> target_link_libraries ( mxnet $ { mshadow_LINKER_LIBS } ) <nl> target_link_libraries ( mxnet dmlccore ) <nl> target_link_libraries ( mxnet pslite ) <nl> mmm a / R - package / R / io . R <nl> ppp b / R - package / R / io . R <nl> mx . io . extract < - function ( iter , field ) { <nl> # ' @ param shuffle Whether shuffle the data <nl> # ' <nl> # ' @ export <nl> - mx . io . arrayiter < - function ( data , label = NULL , <nl> + mx . io . arrayiter < - function ( data , label , <nl> batch . size = 128 , <nl> shuffle = FALSE ) { <nl> + if ( shuffle ) { <nl> + unif . rnds < - as . array ( mx . runif ( c ( length ( label ) ) , ctx = mx . cpu ( ) ) ) ; <nl> + } else { <nl> + unif . rnds < - mx . array ( 0 ) <nl> + } <nl> mx . io . internal . arrayiter ( as . array ( data ) , <nl> as . array ( label ) , <nl> + unif . rnds , <nl> batch . size , <nl> shuffle ) <nl> } <nl> mmm a / R - package / README . md <nl> ppp b / R - package / README . md <nl> <nl> MXNet R - Package <nl> = = = = = = = = = = = = = = = <nl> - The MXNet R packages brings flexible and efficient GPU computing and deep learning to R . <nl> + <nl> + You have find MXNet R Package ! The MXNet R packages brings flexible and efficient GPU <nl> + computing and state - of - art deep learning to R . <nl> <nl> - It enables you to write seamless tensor / matrix computation with multiple GPUs in R . <nl> - It also enables you construct and customize the state - of - art deep learning models in R , <nl> and apply them to tasks such as image classification and data science challenges . <nl> <nl> - Document <nl> mmmmmmmmm <nl> + Sounds exciting ? This page contains links to all the related documents on R package . <nl> + <nl> + Resources <nl> + mmmmmmmmm <nl> * [ MXNet R Package Document ] ( http : / / mxnet . readthedocs . org / en / latest / R - package / index . html ) <nl> - - This is a online hosted documents for mxnet examples etc . <nl> + - Check this out for detailed documents , examples , installation guides . <nl> + <nl> <nl> Installation <nl> mmmmmmmmmmmm <nl> - - First build ` ` ` . . / lib / libmxnet . so ` ` ` by following [ Build Instruction ] ( . . / doc / build . md ) <nl> - - Type ` ` ` R CMD INSTALL R - package ` ` ` in the root folder . <nl> + Follow [ Installation Guide ] ( http : / / mxnet . readthedocs . org / en / latest / build . html ) <nl> + <nl> <nl> mmm a / R - package / demo / basic_training . R <nl> ppp b / R - package / demo / basic_training . R <nl> act2 < - mx . symbol . Activation ( fc2 , name = " relu2 " , act_type = " relu " ) <nl> fc3 < - mx . symbol . FullyConnected ( act2 , name = " fc3 " , num_hidden = 10 ) <nl> softmax < - mx . symbol . Softmax ( fc3 , name = " sm " ) <nl> <nl> - dtrain = mx . varg . io . MNISTIter ( list ( <nl> + dtrain = mx . io . MNISTIter ( <nl> image = " data / train - images - idx3 - ubyte " , <nl> label = " data / train - labels - idx1 - ubyte " , <nl> data . shape = c ( 784 ) , <nl> batch . size = batch . size , <nl> flat = TRUE , <nl> silent = 0 , <nl> - seed = 10 ) ) <nl> + seed = 10 ) <nl> <nl> - dtest = mx . varg . io . MNISTIter ( list ( <nl> + dtest = mx . io . MNISTIter ( <nl> image = " data / t10k - images - idx3 - ubyte " , <nl> label = " data / t10k - labels - idx1 - ubyte " , <nl> data . shape = c ( 784 ) , <nl> batch . size = batch . size , <nl> shuffle = FALSE , <nl> flat = TRUE , <nl> - silent = 0 ) ) <nl> + silent = 0 ) <nl> # X is R ' s array , we load from mxnet ' s native iter structure , but you don ' t have to <nl> X = mx . io . extract ( dtrain , " data " ) <nl> y = mx . io . extract ( dtrain , " label " ) <nl> mmm a / R - package / src / base . h <nl> ppp b / R - package / src / base . h <nl> namespace R { <nl> <nl> / * ! \ brief macro to be compatible with non c + + 11 env * / <nl> # if DMLC_USE_CXX11 = = 0 <nl> + # ifndef nullptr <nl> # define nullptr NULL <nl> # endif <nl> + # endif <nl> <nl> / * ! <nl> * \ brief Log that enables Stop and print message to R console <nl> void SetSeed ( int seed ) ; <nl> * \ brief Base Movable class of MXNet Module object . <nl> * This class will define several common functions . <nl> * \ tparam Class The class name of subclass <nl> - * \ tparam HandleType The type of handle the object have . <nl> - * \ tparam finalizer The free function used to delete the handle . <nl> * / <nl> template < typename Class > <nl> class MXNetMovable { <nl> class MXNetMovable { <nl> protected : <nl> / * ! \ brief default constructor * / <nl> MXNetMovable ( ) : moved_ ( false ) { } <nl> - / * ! <nl> - * \ brief the finalizer for Rcpp <nl> - * \ param self the pointer to the class . <nl> - * / <nl> - inline static void Finalizer ( Class * self ) { <nl> - if ( ! static_cast < MXNetMovable < Class > * > ( self ) - > moved_ ) { <nl> - self - > DoFinalize ( ) ; <nl> - } <nl> - } <nl> / * ! <nl> * \ brief Default implement to Move a existing R Class object to a new one . <nl> * \ param src The source R Object . <nl> class MXNetMovable { <nl> return Rcpp : : internal : : make_new_object ( moved ) ; <nl> } <nl> <nl> - private : <nl> / * ! \ brief Whether the object has been moved * / <nl> bool moved_ ; <nl> } ; <nl> mmm a / R - package / src / executor . cc <nl> ppp b / R - package / src / executor . cc <nl> Executor : : RObjectType Executor : : Bind ( const Symbol : : RObjectType & symbol , <nl> void Executor : : InitRcppModule ( ) { <nl> using namespace Rcpp ; / / NOLINT ( * ) <nl> class_ < Executor > ( " MXExecutor " ) <nl> - . finalizer ( & Executor : : Finalizer ) <nl> . method ( " update . aux . arrays " , <nl> & Executor : : UpdateAuxArray , <nl> " Update auxilary states array of executor , this will mutate the executor " ) <nl> mmm a / R - package / src / executor . h <nl> ppp b / R - package / src / executor . h <nl> class Executor : public MXNetMovable < Executor > { <nl> static void InitRcppModule ( ) ; <nl> / / destructor <nl> ~ Executor ( ) { <nl> - / / delete can handle nullptr safely <nl> delete out_arrays_ ; <nl> delete arg_arrays_ ; <nl> delete grad_arrays_ ; <nl> delete aux_arrays_ ; <nl> + <nl> + if ( ! this - > moved_ ) { <nl> + MX_CALL ( MXExecutorFree ( handle_ ) ) ; <nl> + } <nl> } <nl> <nl> private : <nl> / / friend with symbol <nl> friend class Symbol ; <nl> - friend class MXNetMovable < Executor > ; <nl> / / internal constructor , enable trivial operator = <nl> Executor ( ) <nl> : out_arrays_ ( nullptr ) , <nl> arg_arrays_ ( nullptr ) , <nl> grad_arrays_ ( nullptr ) , <nl> aux_arrays_ ( nullptr ) { } <nl> + <nl> / * ! \ return a new Object that is moved from current one * / <nl> inline Executor * CreateMoveObject ( ) { <nl> Executor * moved = new Executor ( ) ; <nl> class Executor : public MXNetMovable < Executor > { <nl> aux_arrays_ = nullptr ; <nl> return moved ; <nl> } <nl> - / / finalizer that invoked on non - movable object <nl> - inline void DoFinalize ( ) { <nl> - MX_CALL ( MXExecutorFree ( handle_ ) ) ; <nl> - } <nl> / * ! <nl> * \ brief Clone src into a new space . <nl> * \ param src source list of arrays to clone . <nl> mmm a / R - package / src / io . cc <nl> ppp b / R - package / src / io . cc <nl> <nl> <nl> namespace mxnet { <nl> namespace R { <nl> - / / Rcpp random wrapper <nl> - inline size_t RcppRandWrapper ( const size_t n ) { <nl> - return floor ( unif_rand ( ) * n ) ; <nl> - } <nl> <nl> void MXDataIter : : Reset ( ) { <nl> MX_CALL ( MXDataIterBeforeFirst ( handle_ ) ) ; <nl> Rcpp : : List MXDataIter : : Value ( ) const { <nl> <nl> ArrayDataIter : : ArrayDataIter ( const Rcpp : : NumericVector & data , <nl> const Rcpp : : NumericVector & label , <nl> + const Rcpp : : NumericVector & unif_rnds , <nl> int batch_size , <nl> bool shuffle ) : counter_ ( 0 ) { <nl> std : : vector < size_t > order ( label . size ( ) ) ; <nl> for ( size_t i = 0 ; i < order . size ( ) ; + + i ) { <nl> order [ i ] = i ; <nl> } <nl> + <nl> if ( shuffle ) { <nl> - std : : random_shuffle ( order . begin ( ) , order . end ( ) , RcppRandWrapper ) ; <nl> + RCHECK ( unif_rnds . size ( ) = = label . size ( ) ) ; <nl> + for ( size_t i = order . size ( ) - 1 ; i ! = 0 ; - - i ) { <nl> + size_t idx = static_cast < size_t > ( unif_rnds [ i ] * ( i + 1 ) ) ; <nl> + if ( idx < i ) { <nl> + std : : swap ( order [ i ] , order [ idx ] ) ; <nl> + } <nl> + } <nl> } <nl> ArrayDataIter : : Convert ( data , order , batch_size , & data_ ) ; <nl> ArrayDataIter : : Convert ( label , order , batch_size , & label_ ) ; <nl> int ArrayDataIter : : NumPad ( ) const { <nl> <nl> Rcpp : : RObject ArrayDataIter : : Create ( const Rcpp : : NumericVector & data , <nl> const Rcpp : : NumericVector & label , <nl> + const Rcpp : : NumericVector & unif_rnds , <nl> size_t batch_size , <nl> bool shuffle ) { <nl> - return Rcpp : : internal : : make_new_object ( new ArrayDataIter ( data , label , batch_size , shuffle ) ) ; <nl> + return Rcpp : : internal : : make_new_object ( <nl> + new ArrayDataIter ( data , label , unif_rnds , batch_size , shuffle ) ) ; <nl> } <nl> <nl> DataIterCreateFunction : : DataIterCreateFunction <nl> void DataIter : : InitRcppModule ( ) { <nl> . method ( " num . pad " , & DataIter : : NumPad ) ; <nl> <nl> class_ < MXDataIter > ( " MXNativeDataIter " ) <nl> - . derives < DataIter > ( " MXDataIter " ) <nl> - . finalizer ( & MXDataIter : : Finalizer ) ; <nl> + . derives < DataIter > ( " MXDataIter " ) ; <nl> <nl> class_ < ArrayDataIter > ( " MXArrayDataIter " ) <nl> - . derives < DataIter > ( " MXDataIter " ) <nl> - . finalizer ( & ArrayDataIter : : Finalizer ) ; <nl> + . derives < DataIter > ( " MXDataIter " ) ; <nl> <nl> function ( " mx . io . internal . arrayiter " , & ArrayDataIter : : Create ) ; <nl> } <nl> mmm a / R - package / src / io . h <nl> ppp b / R - package / src / io . h <nl> class MXDataIter : public DataIter { <nl> virtual bool Next ( ) ; <nl> virtual int NumPad ( ) const ; <nl> virtual Rcpp : : List Value ( ) const ; <nl> + virtual ~ MXDataIter ( ) { <nl> + MX_CALL ( MXDataIterFree ( handle_ ) ) ; <nl> + } <nl> <nl> private : <nl> friend class DataIter ; <nl> class MXDataIter : public DataIter { <nl> inline static Rcpp : : RObject RObject ( DataIterHandle handle ) { <nl> return Rcpp : : internal : : make_new_object ( new MXDataIter ( handle ) ) ; <nl> } <nl> - / / finalizer that invoked on non - movable object <nl> - static void Finalizer ( MXDataIter * iter ) { <nl> - MX_CALL ( MXDataIterFree ( iter - > handle_ ) ) ; <nl> - } <nl> / * ! \ brief internal data iter handle * / <nl> DataIterHandle handle_ ; <nl> } ; <nl> class ArrayDataIter : public DataIter { <nl> * \ brief Construct a ArrayDataIter from data and label . <nl> * \ param data The data array . <nl> * \ param label The label array . <nl> + * \ param unif_rnds Uniform [ 0 , 1 ] random number of same length as label . <nl> + * Only needed when shuffle = TRUE <nl> * \ param batch_size The size of the batch . <nl> * \ param shuffle Whether shuffle the data . <nl> * / <nl> ArrayDataIter ( const Rcpp : : NumericVector & data , <nl> const Rcpp : : NumericVector & label , <nl> + const Rcpp : : NumericVector & unif_rnds , <nl> int batch_size , <nl> bool shuffle ) ; <nl> virtual void Reset ( ) { <nl> class ArrayDataIter : public DataIter { <nl> virtual Rcpp : : List Value ( ) const ; <nl> static Rcpp : : RObject Create ( const Rcpp : : NumericVector & data , <nl> const Rcpp : : NumericVector & label , <nl> + const Rcpp : : NumericVector & unif_rnds , <nl> size_t batch_size , <nl> bool shuffle ) ; <nl> <nl> class ArrayDataIter : public DataIter { <nl> const std : : vector < size_t > & order , <nl> size_t batch_size , <nl> std : : vector < NDArray > * out ) ; <nl> - / / finalizer that invoked on non - movable object <nl> - static void Finalizer ( ArrayDataIter * iter ) { <nl> - iter - > data_ . clear ( ) ; <nl> - iter - > label_ . clear ( ) ; <nl> - } <nl> / * ! \ brief The counter * / <nl> size_t counter_ ; <nl> / * ! \ brief number of pad instances * / <nl> mmm a / R - package / src / kvstore . cc <nl> ppp b / R - package / src / kvstore . cc <nl> Rcpp : : RObject KVStore : : Create ( const char * type ) { <nl> void KVStore : : InitRcppModule ( ) { <nl> using namespace Rcpp ; / / NOLINT ( * ) <nl> class_ < KVStore > ( " MXKVStore " ) <nl> - . finalizer ( & KVStore : : Finalizer ) <nl> . method ( " init " , & KVStore : : Init ) <nl> . method ( " push " , & KVStore : : Push ) <nl> . method ( " pull " , & KVStore : : Pull ) <nl> mmm a / R - package / src / kvstore . h <nl> ppp b / R - package / src / kvstore . h <nl> class KVStore { <nl> static Rcpp : : RObject Create ( const char * type ) ; <nl> / * ! \ brief initialize the R cpp Module * / <nl> static void InitRcppModule ( ) ; <nl> + / / destructor <nl> + ~ KVStore ( ) { <nl> + MX_CALL ( MXKVStoreFree ( handle_ ) ) ; <nl> + } <nl> <nl> private : <nl> explicit KVStore ( KVStoreHandle handle ) <nl> : handle_ ( handle ) , optimizer_set_ ( false ) { } <nl> - static void Finalizer ( KVStore * kv ) { <nl> - MX_CALL ( MXKVStoreFree ( kv - > handle_ ) ) ; <nl> - } <nl> / / the internal callback to kvstore . <nl> NDArray CreateState ( int index , const NDArray & weight ) const ; <nl> / * ! \ brief internal KVStore handle * / <nl> mmm a / R - package / src / ndarray . h <nl> ppp b / R - package / src / ndarray . h <nl> class NDArray { <nl> / / operator overloading <nl> inline NDArray & operator = ( const NDArray & other ) { <nl> ptr_ = other . ptr_ ; <nl> + return * this ; <nl> } <nl> inline NDBlob * operator - > ( ) { <nl> return ptr_ . get ( ) ; <nl> mmm a / R - package / src / symbol . cc <nl> ppp b / R - package / src / symbol . cc <nl> SEXP SymbolFunction : : operator ( ) ( SEXP * args ) { <nl> void Symbol : : InitRcppModule ( ) { <nl> using namespace Rcpp ; / / NOLINT ( * ) <nl> class_ < Symbol > ( " MXSymbol " ) <nl> - . finalizer ( & Symbol : : Finalizer ) <nl> . method ( " debug . str " , & Symbol : : DebugStr , <nl> " Return the debug string of internals of symbol " ) <nl> . method ( " apply " , & Symbol : : Apply , <nl> mmm a / R - package / src / symbol . h <nl> ppp b / R - package / src / symbol . h <nl> namespace R { <nl> class SymbolFunction ; <nl> <nl> / * ! \ brief The Rcpp Symbol class of MXNet * / <nl> - class Symbol : public MXNetMovable < Symbol > { <nl> + class Symbol { <nl> public : <nl> + / / typedef RObjectType <nl> + typedef Rcpp : : RObject RObjectType ; <nl> / * ! \ return typename from R side . * / <nl> inline static const char * TypeName ( ) { <nl> return " MXSymbol " ; <nl> class Symbol : public MXNetMovable < Symbol > { <nl> static RObjectType Group ( const Rcpp : : List & symbols ) ; <nl> / * ! \ brief static function to initialize the Rcpp functions * / <nl> static void InitRcppModule ( ) ; <nl> + / / destructor <nl> + ~ Symbol ( ) { <nl> + MX_CALL ( MXSymbolFree ( handle_ ) ) ; <nl> + } <nl> + / / get external pointer of Symbol <nl> + inline static Symbol * XPtr ( const Rcpp : : RObject & obj ) { <nl> + return Rcpp : : as < Symbol * > ( obj ) ; <nl> + } <nl> <nl> private : <nl> / / friend with SymbolFunction <nl> friend class SymbolFunction ; <nl> friend class Executor ; <nl> - friend class MXNetMovable < Symbol > ; <nl> / / enable trivial copy constructors etc . <nl> Symbol ( ) { } <nl> / / constructor <nl> class Symbol : public MXNetMovable < Symbol > { <nl> inline static Rcpp : : RObject RObject ( SymbolHandle handle ) { <nl> return Rcpp : : internal : : make_new_object ( new Symbol ( handle ) ) ; <nl> } <nl> - / / Create a new Object that is moved from current one <nl> - inline Symbol * CreateMoveObject ( ) { <nl> - Symbol * moved = new Symbol ( ) ; <nl> - * moved = * this ; <nl> - return moved ; <nl> - } <nl> - / / finalizer that invoked on non - movable object <nl> - inline void DoFinalize ( ) { <nl> - MX_CALL ( MXSymbolFree ( handle_ ) ) ; <nl> - } <nl> / * ! <nl> * \ brief Return a clone of Symbol <nl> * Do not expose to R side <nl> mmm a / doc / R - package / index . md <nl> ppp b / doc / R - package / index . md <nl> <nl> MXNet R Package <nl> = = = = = = = = = = = = = = = <nl> - This page contains links to all the python related documents on R package . <nl> - The MXNet R packages brings flexible and efficient GPU computing and deep learning to R . <nl> + You have find MXNet R Package ! The MXNet R packages brings flexible and efficient GPU <nl> + computing and state - of - art deep learning to R . <nl> <nl> - It enables you to write seamless tensor / matrix computation with multiple GPUs in R . <nl> - It also enables you construct and customize the state - of - art deep learning models in R , <nl> and apply them to tasks such as image classification and data science challenges . <nl> <nl> + Sounds exciting ? This page contains links to all the related documents on R package . <nl> + <nl> + Get Started <nl> + mmmmmmmmm - - <nl> + There are several information to get you started <nl> + * [ Installation Guide ] ( . . / build . md ) contains instructions to install mxnet . <nl> + * [ Tutorials ] ( # tutorials ) contains various examples how how mxnet can be applied to different cool tasks : ) <nl> + * [ Contributor Guide ] ( http : / / mxnet . readthedocs . org / en / latest / contribute . html # r - package ) <nl> + - The R package section gives various guidelines on how to contribute code , tutorial , rmarkdown examples to mxnet . <nl> + - Your contribution is always welcomed ! <nl> + <nl> Tutorials <nl> mmmmmmmmm <nl> * [ Classify Realworld Images with Pretrained Model ] ( classifyRealImageWithPretrainedModel . md ) <nl> * [ Handwritten Digits Classification Competition ] ( mnistCompetition . md ) <nl> * [ Tutorial on NDArray and Symbol ] ( ndarrayAndSymbolTutorial . md ) <nl> <nl> - Installation <nl> mmmmmmmmmmmm - <nl> - - First build ` ` ` . . / lib / libmxnet . so ` ` ` by following [ Build Instruction ] ( . . / doc / build . md ) <nl> - - Type ` ` ` R CMD INSTALL R - package ` ` ` in the root folder . <nl> - <nl> - Contributor Guide <nl> mmmmmmmmmmmmmmmmmm <nl> - * [ Contributor Guide ] ( http : / / mxnet . readthedocs . org / en / latest / contribute . html # r - package ) R package section gives various guidelines on how to contribute code , tutorial , rmarkdown examples to mxnet . <nl> - <nl> mmm a / doc / build . md <nl> ppp b / doc / build . md <nl> <nl> - Build and Installation <nl> - = = = = = = = = = = = = = = = = = = = = = = <nl> + Installation Guide <nl> + = = = = = = = = = = = = = = = = = = <nl> + This page gives the detail of how to install mxnet packages on various systems . <nl> + We tried to listed the detailed , but if the information on this page does not work for you . <nl> + Please ask questions at [ mxnet / issues ] ( https : / / github . com / dmlc / mxnet / issues ) , better still <nl> + if you have ideas to improve this page , please send a pull request ! <nl> + <nl> + Contents <nl> + mmmmmm - - <nl> + - [ Build MXNet Library ] ( # build - mxnet - library ) <nl> + - Introduces how to build the mxnet core library for all packages . <nl> + - Supported platforms : linux , windows , osx <nl> + - [ Advanced Build Configurations ] ( # advanced - build - configuration ) <nl> + - Introduces how to build mxnet with advanced features such as HDFS / S3 support , CUDNN <nl> + - [ Python Package Installation ] ( # python - package - installation ) <nl> + - [ R Package Installation ] ( # r - package - installation ) <nl> + <nl> + Build MXNet Library <nl> + mmmmmmmmmmmmmmmmmm - <nl> + MXNet have a general runtime library that can be used by various packages such as python , R and Julia . <nl> + This section gives details about how to build the mxnet library . <nl> + - On Linux / OSX the target library will be ` ` ` libmxnet . so ` ` ` <nl> + - On Windows the target libary is ` ` ` mxnet . dll ` ` ` <nl> + <nl> + Things to do before get started : <nl> + <nl> + - Clone the project from github <nl> + ` ` ` bash <nl> + git clone - - recursive https : / / github . com / dmlc / mxnet <nl> + ` ` ` <nl> <nl> - Minimal system requirement : <nl> + The system dependency requirement for mxnet libraries are <nl> <nl> - - recent c + + compiler supporting C + + 11 such as ` g + + > = 4 . 8 ` <nl> + - Recent c + + compiler supporting C + + 11 such as ` g + + > = 4 . 8 ` <nl> - git <nl> - BLAS library . <nl> - - opencv <nl> + - opencv ( optional if you do not need image augmentation , you can switch it off in config . mk ) <nl> <nl> - On Ubuntu > = 13 . 10 , one can install them by <nl> + # # # Linux <nl> + <nl> + On Ubuntu > = 13 . 10 , one can install the dependencies by <nl> <nl> ` ` ` bash <nl> sudo apt - get update <nl> sudo apt - get install - y build - essential git libblas - dev libopencv - dev <nl> ` ` ` <nl> <nl> - Then build mxnet <nl> - <nl> + Then build mxnet on the project root <nl> ` ` ` bash <nl> - git clone - - recursive https : / / github . com / dmlc / mxnet <nl> - cd mxnet ; make - j4 <nl> + make - j4 <nl> ` ` ` <nl> + Then proceed to package installation instructions for python or R in this page . <nl> <nl> - To install the python package , first make sure ` python > = 2 . 7 ` and ` numpy > = ? ` are installed , then <nl> + # # # OSX <nl> + On OSX , we can install the dependencies by <nl> <nl> ` ` ` bash <nl> - cd python ; python setup . py install <nl> + brew update <nl> + brew tap homebrew / science <nl> + brew info opencv <nl> + brew install opencv <nl> ` ` ` <nl> <nl> - If anything goes well , now we can train a multilayer perceptron on the hand <nl> - digit recognition dataset . <nl> + - Copy ` ` ` make / osx . mk ` ` ` to project root ` ` ` config . mk ` ` ` . <nl> + ` ` ` bash <nl> + cp make / osx . mk config . mk <nl> + ` ` ` <nl> <nl> + Then build mxnet on the project root <nl> ` ` ` bash <nl> - cd . . ; python example / mnist / mlp . py <nl> + make - j4 <nl> ` ` ` <nl> <nl> - Advanced Build <nl> mmmmmmmmmmmmmmm <nl> + Then proceed to package installation instructions for python or R in this page . <nl> <nl> - - update the repo : <nl> + # # # Windows <nl> <nl> - ` ` ` bash <nl> - git pull <nl> - git submodule update <nl> - ` ` ` <nl> + Firstly , we should make your Visual Studio 2013 support more C + + 11 features . <nl> <nl> - - install python package in developing model , <nl> + - Download and install [ Visual C + + Compiler Nov 2013 CTP ] ( http : / / www . microsoft . com / en - us / download / details . aspx ? id = 41151 ) . <nl> + - Copy all files in ` C : \ Program Files ( x86 ) \ Microsoft Visual C + + Compiler Nov 2013 CTP ` ( or the folder where you extracted the zip archive ) to ` C : \ Program Files ( x86 ) \ Microsoft Visual Studio 12 . 0 \ VC ` and overwrite all existed files . Don ' t forget to backup the original files before copying . <nl> <nl> - ` ` ` bash <nl> - cd python ; python setup . py develop - - user <nl> - ` ` ` <nl> + Secondly , fetch the third - party libraries , including [ OpenCV ] ( http : / / sourceforge . net / projects / opencvlibrary / files / opencv - win / 3 . 0 . 0 / opencv - 3 . 0 . 0 . exe / download ) , [ CuDNN ] ( https : / / developer . nvidia . com / cudnn ) and [ OpenBlas ] ( http : / / sourceforge . net / projects / openblas / files / v0 . 2 . 14 / ) ( ignore this if you have MKL ) . <nl> + <nl> + - NOTICE : You need to register as a NVIDIA community user to get the download link of CuDNN . <nl> + <nl> + Finally , use CMake to create a Visual Studio solution in ` . / build / ` . During configuration , you may need to set the path of each third - party library , until no error is reported . Open the solution and compile , you will get a ` mxnet . dll ` in ` . / build / Release ` or ` . / build / Debug ` . <nl> <nl> + Then proceed to package installation instructions for python or R in this page . <nl> + <nl> + Advanced Build Configurations <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + The configuration of mxnet can be modified by ` ` ` config . mk ` ` ` <nl> - modify the compiling options such as compilers , CUDA , CUDNN , Intel MKL , <nl> various distributed filesystem such as HDFS / Amazon S3 / . . . <nl> - <nl> - First copy [ make / config . mk ] ( . . / make / config . mk ) to the project root , then <nl> + - First copy [ make / config . mk ] ( . . / make / config . mk ) to the project root , then <nl> modify the according flags . <nl> <nl> - Build in Visual Studio 2013 <nl> + Python Package Installation <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + To install the python package . First finish the [ Build MXNet Library ] ( # build - mxnet - library ) step . <nl> + Then use the following command to install mxnet . <nl> <nl> - Firstly , we should make your Visual Studio 2013 support more C + + 11 features . <nl> + ` ` ` bash <nl> + cd python ; python setup . py install <nl> + ` ` ` <nl> <nl> - - Download and install [ Visual C + + Compiler Nov 2013 CTP ] ( http : / / www . microsoft . com / en - us / download / details . aspx ? id = 41151 ) . <nl> - - Copy all files in ` C : \ Program Files ( x86 ) \ Microsoft Visual C + + Compiler Nov 2013 CTP ` ( or the folder where you extracted the zip archive ) to ` C : \ Program Files ( x86 ) \ Microsoft Visual Studio 12 . 0 \ VC ` and overwrite all existed files . Don ' t forget to backup the original files before copying . <nl> + If anything goes well , now we can train a multilayer perceptron on the hand <nl> + digit recognition dataset . <nl> <nl> - Secondly , fetch the third - party libraries , including [ OpenCV ] ( http : / / sourceforge . net / projects / opencvlibrary / files / opencv - win / 3 . 0 . 0 / opencv - 3 . 0 . 0 . exe / download ) , [ CuDNN ] ( https : / / developer . nvidia . com / cudnn ) and [ OpenBlas ] ( http : / / sourceforge . net / projects / openblas / files / v0 . 2 . 14 / ) ( ignore this if you have MKL ) . <nl> + ` ` ` bash <nl> + cd . . ; python example / mnist / mlp . py <nl> + ` ` ` <nl> <nl> - - NOTICE : You need to register as a NVIDIA community user to get the download link of CuDNN . <nl> + YOu can also install python to your user directory instead of root . <nl> <nl> - Finally , use CMake to create a Visual Studio solution in ` . / build / ` . During configuration , you may need to set the path of each third - party library , until no error is reported . Open the solution and compile , you will get a ` mxnet . dll ` in ` . / build / Release ` or ` . / build / Debug ` . <nl> + ` ` ` bash <nl> + cd python ; python setup . py develop - - user <nl> + ` ` ` <nl> + <nl> + R Package Installation <nl> + mmmmmmmmmmmmmmmmmmmmm - <nl> + To install the python package . First finish the [ Build MXNet Library ] ( # build - mxnet - library ) step . <nl> + Then use the following command to install mxnet at root folder <nl> + <nl> + ` ` ` bash <nl> + R CMD INSTALL R - Package <nl> + ` ` ` <nl> + <nl> + Hopefully , we will now have mxnet on R ! <nl> <nl> - The following steps are the same with Linux . <nl> + # # Note on Library Build <nl> + We isolate the library build with Rcpp end to maximize the portability <nl> + - MSVC is needed on windows to build the mxnet library , because of CUDA compatiblity issue of toolchains . <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . cf5d040732d <nl> mmm / dev / null <nl> ppp b / make / osx . mk <nl> <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # Template configuration for compiling mxnet <nl> + # <nl> + # If you want to change the configuration , please use the following <nl> + # steps . Assume you are on the root directory of mxnet . First copy the this <nl> + # file so that any local changes will be ignored by git <nl> + # <nl> + # $ cp make / config . mk . <nl> + # <nl> + # Next modify the according entries , and then compile by <nl> + # <nl> + # $ make <nl> + # <nl> + # or build in parallel with 8 threads <nl> + # <nl> + # $ make - j8 <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmm <nl> + # choice of compiler <nl> + # mmmmmmmmmmmmmmmmmm - - <nl> + <nl> + export CC = gcc <nl> + export CXX = g + + <nl> + export NVCC = nvcc <nl> + <nl> + # whether compile with debug <nl> + DEBUG = 0 <nl> + <nl> + # the additional link flags you want to add <nl> + ADD_LDFLAGS = <nl> + <nl> + # the additional compile flags you want to add <nl> + ADD_CFLAGS = <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + # matrix computation libraries for CPU / GPU <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + # whether use CUDA during compile <nl> + USE_CUDA = 0 <nl> + <nl> + # add the path to CUDA libary to link and compile flag <nl> + # if you have already add them to enviroment variable , leave it as NONE <nl> + # USE_CUDA_PATH = / usr / local / cuda <nl> + USE_CUDA_PATH = NONE <nl> + <nl> + # whether use CUDNN R3 library <nl> + USE_CUDNN = 0 <nl> + <nl> + # whether use opencv during compilation <nl> + # you can disable it , however , you will not able to use <nl> + # imbin iterator <nl> + USE_OPENCV = 1 <nl> + <nl> + # use openmp for parallelization <nl> + USE_OPENMP = 0 <nl> + <nl> + # choose the version of blas you want to use <nl> + # can be : mkl , blas , atlas , openblas <nl> + USE_BLAS = apple <nl> + <nl> + # add path to intel libary , you may need it for MKL , if you did not add the path <nl> + # to enviroment variable <nl> + USE_INTEL_PATH = NONE <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # distributed computing <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + # whether or not to enable mullti - machine supporting <nl> + USE_DIST_KVSTORE = 0 <nl> + <nl> + # whether or not allow to read and write HDFS directly . If yes , then hadoop is <nl> + # required <nl> + USE_HDFS = 0 <nl> + <nl> + # path to libjvm . so . required if USE_HDFS = 1 <nl> + LIBJVM = $ ( JAVA_HOME ) / jre / lib / amd64 / server <nl> + <nl> + # whether or not allow to read and write AWS S3 directly . If yes , then <nl> + # libcurl4 - openssl - dev is required , it can be installed on Ubuntu by <nl> + # sudo apt - get install - y libcurl4 - openssl - dev <nl> + USE_S3 = 0 <nl> mmm a / mshadow <nl> ppp b / mshadow <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 9aaa23b559990bb9354254e607e52e493fd8f7b9 <nl> + Subproject commit d2c27549571fb6a71e81d8b860b1484809d8922f <nl> mmm a / python / setup . py <nl> ppp b / python / setup . py <nl> <nl> version = __version__ , <nl> description = open ( os . path . join ( CURRENT_DIR , ' README . md ' ) ) . read ( ) , <nl> install_requires = [ <nl> - ' numpy ' , <nl> - ] , <nl> + ' numpy ' , <nl> + ] , <nl> zip_safe = False , <nl> packages = [ ' mxnet ' ] , <nl> data_files = [ ( ' mxnet ' , [ LIB_PATH [ 0 ] ] ) ] , <nl> | Merge pull request from tqchen / master | apache/incubator-mxnet | dd37e6738e244e4d578194384500a135bbd8713d | 2015-10-18T04:41:57Z |
mmm a / ports / yaml - cpp / portfile . cmake <nl> ppp b / ports / yaml - cpp / portfile . cmake <nl> get_filename_component ( _IMPORT_PREFIX \ " \ $ { _IMPORT_PREFIX } \ " PATH ) <nl> get_filename_component ( _IMPORT_PREFIX \ " \ $ { _IMPORT_PREFIX } \ " PATH ) " YAML_CONFIG " $ { YAML_CONFIG } " ) <nl> file ( WRITE $ { CURRENT_PACKAGES_DIR } / share / yaml - cpp / yaml - cpp - targets . cmake " $ { YAML_CONFIG } " ) <nl> <nl> - foreach ( CONF debug release ) <nl> + set ( _targets_cmake_conf ) <nl> + if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL " debug " ) <nl> + list ( APPEND _targets_cmake_conf " debug " ) <nl> + endif ( ) <nl> + if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL " release " ) <nl> + list ( APPEND _targets_cmake_conf " release " ) <nl> + endif ( ) <nl> + foreach ( CONF $ { _targets_cmake_conf } ) <nl> file ( READ $ { CURRENT_PACKAGES_DIR } / share / yaml - cpp / yaml - cpp - targets - $ { CONF } . cmake YAML_CONFIG ) <nl> string ( REPLACE " $ { CURRENT_PACKAGES_DIR } " " \ $ { _IMPORT_PREFIX } " YAML_CONFIG " $ { YAML_CONFIG } " ) <nl> file ( WRITE $ { CURRENT_PACKAGES_DIR } / share / yaml - cpp / yaml - cpp - targets - $ { CONF } . cmake " $ { YAML_CONFIG } " ) <nl> | [ yaml - cpp ] Fix build failure when VCPKG_BUILD_TYPE is set | microsoft/vcpkg | 27016a9b310583e97fd83f74b701fbb1aa38a560 | 2018-03-19T22:26:06Z |
mmm a / dbms / src / Storages / LiveView / StorageLiveView . cpp <nl> ppp b / dbms / src / Storages / LiveView / StorageLiveView . cpp <nl> <nl> - / * iopyright ( c ) 2018 BlackBerry Limited <nl> + / * Copyright ( c ) 2018 BlackBerry Limited <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> static void extractDependentTable ( ASTPtr & query , String & select_database_name , <nl> DB : : ErrorCodes : : LOGICAL_ERROR ) ; <nl> } <nl> <nl> - BlocksPtrs StorageLiveView : : collectMergeableBlocks ( const Context & context ) <nl> + MergeableBlocksPtr StorageLiveView : : collectMergeableBlocks ( const Context & context ) <nl> { <nl> ASTPtr mergeable_query = inner_query ; <nl> <nl> if ( inner_subquery ) <nl> mergeable_query = inner_subquery ; <nl> <nl> - BlocksPtrs new_mergeable_blocks = std : : make_shared < std : : vector < BlocksPtr > > ( ) ; <nl> - BlocksPtr base_mergeable_blocks = std : : make_shared < Blocks > ( ) ; <nl> + MergeableBlocksPtr new_mergeable_blocks = std : : make_shared < MergeableBlocks > ( ) ; <nl> + BlocksPtrs new_blocks = std : : make_shared < std : : vector < BlocksPtr > > ( ) ; <nl> + BlocksPtr base_blocks = std : : make_shared < Blocks > ( ) ; <nl> <nl> - InterpreterSelectQuery interpreter ( mergeable_query , context , SelectQueryOptions ( QueryProcessingStage : : WithMergeableState ) , Names ( ) ) ; <nl> + InterpreterSelectQuery interpreter ( mergeable_query - > clone ( ) , context , SelectQueryOptions ( QueryProcessingStage : : WithMergeableState ) , Names ( ) ) ; <nl> <nl> auto view_mergeable_stream = std : : make_shared < MaterializingBlockInputStream > ( interpreter . execute ( ) . in ) ; <nl> <nl> while ( Block this_block = view_mergeable_stream - > read ( ) ) <nl> - base_mergeable_blocks - > push_back ( this_block ) ; <nl> + base_blocks - > push_back ( this_block ) ; <nl> <nl> - new_mergeable_blocks - > push_back ( base_mergeable_blocks ) ; <nl> + new_blocks - > push_back ( base_blocks ) ; <nl> <nl> - mergeable_blocks = new_mergeable_blocks ; <nl> + new_mergeable_blocks - > blocks = new_blocks ; <nl> + new_mergeable_blocks - > sample_block = view_mergeable_stream - > getHeader ( ) ; <nl> <nl> - return mergeable_blocks ; <nl> + return new_mergeable_blocks ; <nl> } <nl> <nl> - BlockInputStreams StorageLiveView : : blocksToInputStreams ( BlocksPtrs blocks ) <nl> + BlockInputStreams StorageLiveView : : blocksToInputStreams ( BlocksPtrs blocks , Block & sample_block ) <nl> { <nl> BlockInputStreams streams ; <nl> - <nl> for ( auto & blocks_ : * blocks ) <nl> { <nl> - if ( blocks_ - > empty ( ) ) <nl> - continue ; <nl> - <nl> - auto sample_block = blocks_ - > front ( ) . cloneEmpty ( ) ; <nl> - <nl> BlockInputStreamPtr stream = std : : make_shared < BlocksBlockInputStream > ( std : : make_shared < BlocksPtr > ( blocks_ ) , sample_block ) ; <nl> - <nl> streams . push_back ( std : : move ( stream ) ) ; <nl> } <nl> return streams ; <nl> } <nl> <nl> / / / Complete query using input streams from mergeable blocks <nl> - BlockInputStreamPtr StorageLiveView : : completeQuery ( BlockInputStreams & from ) <nl> + BlockInputStreamPtr StorageLiveView : : completeQuery ( BlockInputStreams from ) <nl> { <nl> auto block_context = std : : make_unique < Context > ( global_context ) ; <nl> block_context - > makeQueryContext ( ) ; <nl> void StorageLiveView : : writeIntoLiveView ( <nl> const Context & context ) <nl> { <nl> BlockOutputStreamPtr output = std : : make_shared < LiveViewBlockOutputStream > ( live_view ) ; <nl> - auto block_context = std : : make_unique < Context > ( context . getGlobalContext ( ) ) ; <nl> - block_context - > makeQueryContext ( ) ; <nl> <nl> / / / Check if live view has any readers if not <nl> / / / just reset blocks to empty and do nothing else <nl> void StorageLiveView : : writeIntoLiveView ( <nl> <nl> bool is_block_processed = false ; <nl> BlockInputStreams from ; <nl> - BlocksPtrs mergeable_blocks ; <nl> + MergeableBlocksPtr mergeable_blocks ; <nl> BlocksPtr new_mergeable_blocks = std : : make_shared < Blocks > ( ) ; <nl> - ASTPtr mergeable_query = live_view . getInnerQuery ( ) ; <nl> - <nl> - if ( live_view . getInnerSubQuery ( ) ) <nl> - mergeable_query = live_view . getInnerSubQuery ( ) ; <nl> <nl> { <nl> std : : lock_guard lock ( live_view . mutex ) ; <nl> <nl> mergeable_blocks = live_view . getMergeableBlocks ( ) ; <nl> - if ( ! mergeable_blocks | | mergeable_blocks - > size ( ) > = context . getGlobalContext ( ) . getSettingsRef ( ) . max_live_view_insert_blocks_before_refresh ) <nl> + if ( ! mergeable_blocks | | mergeable_blocks - > blocks - > size ( ) > = context . getGlobalContext ( ) . getSettingsRef ( ) . max_live_view_insert_blocks_before_refresh ) <nl> { <nl> mergeable_blocks = live_view . collectMergeableBlocks ( context ) ; <nl> - from = live_view . blocksToInputStreams ( mergeable_blocks ) ; <nl> + live_view . setMergeableBlocks ( mergeable_blocks ) ; <nl> + from = live_view . blocksToInputStreams ( mergeable_blocks - > blocks , mergeable_blocks - > sample_block ) ; <nl> is_block_processed = true ; <nl> } <nl> } <nl> <nl> if ( ! is_block_processed ) <nl> { <nl> - BlockInputStreams streams = { std : : make_shared < OneBlockInputStream > ( block ) } ; <nl> + ASTPtr mergeable_query = live_view . getInnerQuery ( ) ; <nl> + <nl> + if ( live_view . getInnerSubQuery ( ) ) <nl> + mergeable_query = live_view . getInnerSubQuery ( ) ; <nl> + <nl> + BlockInputStreams streams = { std : : make_shared < OneBlockInputStream > ( block ) } ; <nl> <nl> auto blocks_storage = StorageBlocks : : createStorage ( live_view . database_name , live_view . table_name , <nl> live_view . getParentStorage ( ) - > getColumns ( ) , std : : move ( streams ) , QueryProcessingStage : : FetchColumns ) ; <nl> void StorageLiveView : : writeIntoLiveView ( <nl> std : : lock_guard lock ( live_view . mutex ) ; <nl> <nl> mergeable_blocks = live_view . getMergeableBlocks ( ) ; <nl> - mergeable_blocks - > push_back ( new_mergeable_blocks ) ; <nl> - from = live_view . blocksToInputStreams ( mergeable_blocks ) ; <nl> + mergeable_blocks - > blocks - > push_back ( new_mergeable_blocks ) ; <nl> + from = live_view . blocksToInputStreams ( mergeable_blocks - > blocks , mergeable_blocks - > sample_block ) ; <nl> } <nl> } <nl> <nl> bool StorageLiveView : : getNewBlocks ( ) <nl> UInt128 key ; <nl> BlocksPtr new_blocks = std : : make_shared < Blocks > ( ) ; <nl> BlocksMetadataPtr new_blocks_metadata = std : : make_shared < BlocksMetadata > ( ) ; <nl> - BlocksPtr new_mergeable_blocks = std : : make_shared < Blocks > ( ) ; <nl> - ASTPtr mergeable_query = inner_query ; <nl> - <nl> - if ( inner_subquery ) <nl> - mergeable_query = inner_subquery ; <nl> - <nl> - InterpreterSelectQuery interpreter ( mergeable_query - > clone ( ) , * live_view_context , SelectQueryOptions ( QueryProcessingStage : : WithMergeableState ) , Names ( ) ) ; <nl> - auto mergeable_stream = std : : make_shared < MaterializingBlockInputStream > ( interpreter . execute ( ) . in ) ; <nl> <nl> - while ( Block block = mergeable_stream - > read ( ) ) <nl> - new_mergeable_blocks - > push_back ( block ) ; <nl> - <nl> - auto block_context = std : : make_unique < Context > ( global_context ) ; <nl> - block_context - > makeQueryContext ( ) ; <nl> - <nl> - mergeable_blocks = std : : make_shared < std : : vector < BlocksPtr > > ( ) ; <nl> - mergeable_blocks - > push_back ( new_mergeable_blocks ) ; <nl> - BlockInputStreamPtr from = std : : make_shared < BlocksBlockInputStream > ( std : : make_shared < BlocksPtr > ( new_mergeable_blocks ) , mergeable_stream - > getHeader ( ) ) ; <nl> - <nl> - auto blocks_storage = StorageBlocks : : createStorage ( database_name , table_name , global_context . getTable ( select_database_name , select_table_name ) - > getColumns ( ) , { from } , QueryProcessingStage : : WithMergeableState ) ; <nl> - block_context - > addExternalTable ( table_name + " _blocks " , blocks_storage ) ; <nl> - <nl> - InterpreterSelectQuery select ( inner_blocks_query - > clone ( ) , * block_context , StoragePtr ( ) , SelectQueryOptions ( QueryProcessingStage : : Complete ) ) ; <nl> - BlockInputStreamPtr data = std : : make_shared < MaterializingBlockInputStream > ( select . execute ( ) . in ) ; <nl> - <nl> - / / / Squashing is needed here because the view query can generate a lot of blocks <nl> - / / / even when only one block is inserted into the parent table ( e . g . if the query is a GROUP BY <nl> - / / / and two - level aggregation is triggered ) . <nl> - data = std : : make_shared < SquashingBlockInputStream > ( <nl> - data , global_context . getSettingsRef ( ) . min_insert_block_size_rows , global_context . getSettingsRef ( ) . min_insert_block_size_bytes ) ; <nl> + mergeable_blocks = collectMergeableBlocks ( * live_view_context ) ; <nl> + BlockInputStreams from = blocksToInputStreams ( mergeable_blocks - > blocks , mergeable_blocks - > sample_block ) ; <nl> + BlockInputStreamPtr data = completeQuery ( { from } ) ; <nl> <nl> while ( Block block = data - > read ( ) ) <nl> { <nl> mmm a / dbms / src / Storages / LiveView / StorageLiveView . h <nl> ppp b / dbms / src / Storages / LiveView / StorageLiveView . h <nl> struct BlocksMetadata <nl> UInt64 version ; <nl> } ; <nl> <nl> + struct MergeableBlocks <nl> + { <nl> + BlocksPtrs blocks ; <nl> + Block sample_block ; <nl> + } ; <nl> + <nl> class IAST ; <nl> using ASTPtr = std : : shared_ptr < IAST > ; <nl> using BlocksMetadataPtr = std : : shared_ptr < BlocksMetadata > ; <nl> + using MergeableBlocksPtr = std : : shared_ptr < MergeableBlocks > ; <nl> <nl> class StorageLiveView : public ext : : shared_ptr_helper < StorageLiveView > , public IStorage <nl> { <nl> friend class LiveViewBlockOutputStream ; <nl> unsigned num_streams ) override ; <nl> <nl> std : : shared_ptr < BlocksPtr > getBlocksPtr ( ) { return blocks_ptr ; } <nl> - BlocksPtrs getMergeableBlocks ( ) { return mergeable_blocks ; } <nl> + MergeableBlocksPtr getMergeableBlocks ( ) { return mergeable_blocks ; } <nl> <nl> - / / / collect and set mergeable blocks . Must be called holding mutex <nl> - BlocksPtrs collectMergeableBlocks ( const Context & context ) ; <nl> + / / / Collect mergeable blocks and their sample . Must be called holding mutex <nl> + MergeableBlocksPtr collectMergeableBlocks ( const Context & context ) ; <nl> / / / Complete query using input streams from mergeable blocks <nl> - BlockInputStreamPtr completeQuery ( BlockInputStreams & from ) ; <nl> + BlockInputStreamPtr completeQuery ( BlockInputStreams from ) ; <nl> <nl> - void setMergeableBlocks ( BlocksPtrs blocks ) { mergeable_blocks = blocks ; } <nl> + void setMergeableBlocks ( MergeableBlocksPtr blocks ) { mergeable_blocks = blocks ; } <nl> std : : shared_ptr < bool > getActivePtr ( ) { return active_ptr ; } <nl> <nl> / / / Read new data blocks that store query result <nl> friend class LiveViewBlockOutputStream ; <nl> Block getHeader ( ) const ; <nl> <nl> / / / convert blocks to input streams <nl> - static BlockInputStreams blocksToInputStreams ( BlocksPtrs blocks ) ; <nl> + static BlockInputStreams blocksToInputStreams ( BlocksPtrs blocks , Block & sample_block ) ; <nl> <nl> static void writeIntoLiveView ( <nl> StorageLiveView & live_view , <nl> friend class LiveViewBlockOutputStream ; <nl> std : : shared_ptr < BlocksPtr > blocks_ptr ; <nl> / / / Current data blocks metadata <nl> std : : shared_ptr < BlocksMetadataPtr > blocks_metadata_ptr ; <nl> - BlocksPtrs mergeable_blocks ; <nl> + MergeableBlocksPtr mergeable_blocks ; <nl> <nl> / / / Background thread for temporary tables <nl> / / / which drops this table if there are no users <nl> | Updates to make all live view tests to pass . | ClickHouse/ClickHouse | 25458a486589290549d251eaa1b23218682a6853 | 2020-01-03T01:48:15Z |
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 7f4492d60065fcb188770b992dce80d44a3be614 <nl> + Subproject commit 3c383a2d506c122c30b90ffecc7ef21f57ee5dc3 <nl> mmm a / build / deps / github_hashes / facebook / wangle - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / wangle - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 8e4a2f5815c1e0c04307667df905d2a4f10cb1b5 <nl> + Subproject commit 6e7a73a1ebfc45f07334fdb8a76c379e73a82816 <nl> | Updating submodules | facebook/watchman | 7f4acfdc8116e667db463eb4bd20405fccef8bc4 | 2019-11-22T07:30:29Z |
new file mode 100644 <nl> index 000000000 . . fd3224d20 <nl> mmm / dev / null <nl> ppp b / example / thrift_extension_c + + / client2 . cpp <nl> <nl> + / / Copyright ( c ) 2014 Baidu , Inc . <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> + / / A client sending requests to server by multiple threads . <nl> + <nl> + # include " gen - cpp / echo_types . h " <nl> + <nl> + # include < gflags / gflags . h > <nl> + # include < bthread / bthread . h > <nl> + # include < butil / logging . h > <nl> + # include < brpc / server . h > <nl> + # include < brpc / channel . h > <nl> + # include < brpc / thrift_message . h > <nl> + # include < bvar / bvar . h > <nl> + <nl> + DEFINE_int32 ( thread_num , 50 , " Number of threads to send requests " ) ; <nl> + DEFINE_bool ( use_bthread , false , " Use bthread to send requests " ) ; <nl> + DEFINE_int32 ( request_size , 16 , " Bytes of each request " ) ; <nl> + DEFINE_string ( connection_type , " " , " Connection type . Available values : single , pooled , short " ) ; <nl> + DEFINE_string ( server , " 0 . 0 . 0 . 0 : 8019 " , " IP Address of server " ) ; <nl> + DEFINE_string ( load_balancer , " " , " The algorithm for load balancing " ) ; <nl> + DEFINE_int32 ( timeout_ms , 100 , " RPC timeout in milliseconds " ) ; <nl> + DEFINE_int32 ( max_retry , 3 , " Max retries ( not including the first RPC ) " ) ; <nl> + DEFINE_bool ( dont_fail , false , " Print fatal when some call failed " ) ; <nl> + DEFINE_bool ( enable_ssl , false , " Use SSL connection " ) ; <nl> + DEFINE_int32 ( dummy_port , - 1 , " Launch dummy server at this port " ) ; <nl> + <nl> + std : : string g_request ; <nl> + <nl> + bvar : : LatencyRecorder g_latency_recorder ( " client " ) ; <nl> + bvar : : Adder < int > g_error_count ( " client_error_count " ) ; <nl> + <nl> + static void * sender ( void * arg ) { <nl> + / / Normally , you should not call a Channel directly , but instead construct <nl> + / / a stub Service wrapping it . stub can be shared by all threads as well . <nl> + brpc : : ThriftStub stub ( static_cast < brpc : : Channel * > ( arg ) ) ; <nl> + <nl> + while ( ! brpc : : IsAskedToQuit ( ) ) { <nl> + / / We will receive response synchronously , safe to put variables <nl> + / / on stack . <nl> + example : : EchoRequest req ; <nl> + example : : EchoResponse res ; <nl> + brpc : : Controller cntl ; <nl> + <nl> + req . __set_data ( g_request ) ; <nl> + req . __set_need_by_proxy ( 10 ) ; <nl> + <nl> + / / Because ` done ' ( last parameter ) is NULL , this function waits until <nl> + / / the response comes back or error occurs ( including timedout ) . <nl> + stub . CallMethod ( " Echo " , & cntl , & req , & res , NULL ) ; <nl> + if ( ! cntl . Failed ( ) ) { <nl> + g_latency_recorder < < cntl . latency_us ( ) ; <nl> + } else { <nl> + g_error_count < < 1 ; <nl> + CHECK ( brpc : : IsAskedToQuit ( ) | | ! FLAGS_dont_fail ) <nl> + < < " error = " < < cntl . ErrorText ( ) < < " latency = " < < cntl . latency_us ( ) ; <nl> + / / We can ' t connect to the server , sleep a while . Notice that this <nl> + / / is a specific sleeping to prevent this thread from spinning too <nl> + / / fast . You should continue the business logic in a production <nl> + / / server rather than sleeping . <nl> + bthread_usleep ( 50000 ) ; <nl> + } <nl> + } <nl> + return NULL ; <nl> + } <nl> + <nl> + int main ( int argc , char * argv [ ] ) { <nl> + / / Parse gflags . We recommend you to use gflags as well . <nl> + GFLAGS_NS : : ParseCommandLineFlags ( & argc , & argv , true ) ; <nl> + <nl> + / / A Channel represents a communication line to a Server . Notice that <nl> + / / Channel is thread - safe and can be shared by all threads in your program . <nl> + brpc : : Channel channel ; <nl> + <nl> + / / Initialize the channel , NULL means using default options . <nl> + brpc : : ChannelOptions options ; <nl> + options . ssl_options . enable = FLAGS_enable_ssl ; <nl> + options . protocol = brpc : : PROTOCOL_THRIFT ; <nl> + options . connection_type = FLAGS_connection_type ; <nl> + options . connect_timeout_ms = std : : min ( FLAGS_timeout_ms / 2 , 100 ) ; <nl> + options . timeout_ms = FLAGS_timeout_ms ; <nl> + options . max_retry = FLAGS_max_retry ; <nl> + if ( channel . Init ( FLAGS_server . c_str ( ) , FLAGS_load_balancer . c_str ( ) , & options ) ! = 0 ) { <nl> + LOG ( ERROR ) < < " Fail to initialize channel " ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + if ( FLAGS_request_size < = 0 ) { <nl> + LOG ( ERROR ) < < " Bad request_size = " < < FLAGS_request_size ; <nl> + return - 1 ; <nl> + } <nl> + g_request . resize ( FLAGS_request_size , ' r ' ) ; <nl> + <nl> + if ( FLAGS_dummy_port > = 0 ) { <nl> + brpc : : StartDummyServerAt ( FLAGS_dummy_port ) ; <nl> + } <nl> + <nl> + std : : vector < bthread_t > bids ; <nl> + std : : vector < pthread_t > pids ; <nl> + if ( ! FLAGS_use_bthread ) { <nl> + pids . resize ( FLAGS_thread_num ) ; <nl> + for ( int i = 0 ; i < FLAGS_thread_num ; + + i ) { <nl> + if ( pthread_create ( & pids [ i ] , NULL , sender , & channel ) ! = 0 ) { <nl> + LOG ( ERROR ) < < " Fail to create pthread " ; <nl> + return - 1 ; <nl> + } <nl> + } <nl> + } else { <nl> + bids . resize ( FLAGS_thread_num ) ; <nl> + for ( int i = 0 ; i < FLAGS_thread_num ; + + i ) { <nl> + if ( bthread_start_background ( <nl> + & bids [ i ] , NULL , sender , & channel ) ! = 0 ) { <nl> + LOG ( ERROR ) < < " Fail to create bthread " ; <nl> + return - 1 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + while ( ! brpc : : IsAskedToQuit ( ) ) { <nl> + sleep ( 1 ) ; <nl> + LOG ( INFO ) < < " Sending EchoRequest at qps = " < < g_latency_recorder . qps ( 1 ) <nl> + < < " latency = " < < g_latency_recorder . latency ( 1 ) ; <nl> + } <nl> + <nl> + LOG ( INFO ) < < " EchoClient is going to quit " ; <nl> + for ( int i = 0 ; i < FLAGS_thread_num ; + + i ) { <nl> + if ( ! FLAGS_use_bthread ) { <nl> + pthread_join ( pids [ i ] , NULL ) ; <nl> + } else { <nl> + bthread_join ( bids [ i ] , NULL ) ; <nl> + } <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> mmm a / src / brpc / socket_map . cpp <nl> ppp b / src / brpc / socket_map . cpp <nl> void SocketMapList ( std : : vector < SocketId > * ids ) { <nl> SocketMap * m = get_client_side_socket_map ( ) ; <nl> if ( m ) { <nl> m - > List ( ids ) ; <nl> + } else { <nl> + ids - > clear ( ) ; <nl> } <nl> } <nl> <nl> | fix the bug in SocketMapList that input is not cleared when socketmap is not created & add a multi - threaded client for thrift | apache/incubator-brpc | 3fccb30174ee4bda07094271f88ab96a48dcecdd | 2018-07-18T09:55:47Z |
mmm a / src / compiler / python_generator . cc <nl> ppp b / src / compiler / python_generator . cc <nl> bool PythonGrpcGenerator : : Generate ( const FileDescriptor * file , <nl> <nl> ProtoBufFile pbfile ( file ) ; <nl> PrivateGenerator generator ( config_ , & pbfile ) ; <nl> - if ( parameter = = " grpc_2_0 " ) { <nl> + if ( parameter = = " " | | parameter = = " grpc_2_0 " ) { <nl> return GenerateGrpc ( context , generator , pb2_grpc_file_name , true ) ; <nl> - } else if ( parameter = = " grpc_1_0 " | | parameter = = " " ) { <nl> + } else if ( parameter = = " grpc_1_0 " ) { <nl> return GenerateGrpc ( context , generator , pb2_grpc_file_name , true ) & & <nl> GenerateGrpc ( context , generator , pb2_file_name , false ) ; <nl> } else { <nl> | Merge pull request from nathanielmanistaatgoogle / grpc_1_0_flag | grpc/grpc | 574faf3b0523deec4815aac426843fa0a0fd787b | 2017-09-19T18:03:33Z |
mmm a / tensorflow / python / eager / function . py <nl> ppp b / tensorflow / python / eager / function . py <nl> def _canonicalize_function_inputs ( self , * args , * * kwargs ) : <nl> except ( ValueError , TypeError ) : <nl> raise ValueError ( " Structure of Python function inputs does not match " <nl> " input_signature . " ) <nl> - if any ( not isinstance ( arg , ops . Tensor ) for arg in flat_inputs ) : <nl> + if any ( not pywrap_tensorflow . IsTensor ( arg ) for arg in flat_inputs ) : <nl> raise ValueError ( " When input_signature is provided , all inputs to " <nl> " the Python function must be Tensors . " ) <nl> - tensor_specs = [ <nl> - tensor_spec . TensorSpec . from_tensor ( tensor ) for tensor in flat_inputs <nl> - ] <nl> if any ( not spec . is_compatible_with ( other ) <nl> - for spec , other in zip ( self . _flat_input_signature , tensor_specs ) ) : <nl> + for spec , other in zip ( self . _flat_input_signature , flat_inputs ) ) : <nl> raise ValueError ( " Python inputs incompatible with input_signature : " <nl> " inputs ( % s ) , input_signature ( % s ) " % <nl> ( str ( inputs ) , str ( self . _input_signature ) ) ) <nl> mmm a / tensorflow / python / util / util . i <nl> ppp b / tensorflow / python / util / util . i <nl> limitations under the License . <nl> % unignore tensorflow : : swig : : RegisterType ; <nl> % noexception tensorflow : : swig : : RegisterType ; <nl> <nl> + % unignore tensorflow : : swig : : IsTensor ; <nl> + % noexception tensorflow : : swig : : IsTensor ; <nl> + <nl> % feature ( " docstring " ) tensorflow : : swig : : IsSequence <nl> " " " Returns a true if its input is a collections . Sequence ( except strings ) . <nl> <nl> | Stop creating unnecessary tensor_specs , and use caching IsTensor check . | tensorflow/tensorflow | 3cd85a0c541dcf3b86e5da5a20b1b4680b6a865a | 2018-10-17T19:23:22Z |
mmm a / src / mongo / db / catalog / index_catalog_entry_impl . cpp <nl> ppp b / src / mongo / db / catalog / index_catalog_entry_impl . cpp <nl> bool IndexCatalogEntryImpl : : isReady ( OperationContext * opCtx ) const { <nl> / / minimumSnapshotVersion on a collection . This means we are unprotected from reading <nl> / / out - of - sync index catalog entries . To fix this , we uassert if we detect that the <nl> / / in - memory catalog is out - of - sync with the on - disk catalog . <nl> - if ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> if ( ! _catalogIsPresent ( opCtx ) | | _catalogIsReady ( opCtx ) ! = _isReady ) { <nl> uasserted ( ErrorCodes : : SnapshotUnavailable , <nl> str : : stream ( ) < < " Unable to read from a snapshot due to pending collection " <nl> bool IndexCatalogEntryImpl : : isMultikey ( OperationContext * opCtx ) const { <nl> / / and the read - path will query this state before determining there is no interesting multikey <nl> / / state . Note , it ' s always legal , though potentially wasteful , to return ` true ` . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( ! txnParticipant | | ! txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( ! txnParticipant | | ! txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> return false ; <nl> } <nl> <nl> - for ( const MultikeyPathInfo & path : txnParticipant - > getUncommittedMultikeyPathInfos ( ) ) { <nl> + for ( const MultikeyPathInfo & path : txnParticipant . getUncommittedMultikeyPathInfos ( ) ) { <nl> if ( path . nss = = NamespaceString ( _ns ) & & path . indexName = = _descriptor - > indexName ( ) ) { <nl> return true ; <nl> } <nl> MultikeyPaths IndexCatalogEntryImpl : : getMultikeyPaths ( OperationContext * opCtx ) c <nl> stdx : : lock_guard < stdx : : mutex > lk ( _indexMultikeyPathsMutex ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( ! txnParticipant | | ! txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( ! txnParticipant | | ! txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> return _indexMultikeyPaths ; <nl> } <nl> <nl> MultikeyPaths ret = _indexMultikeyPaths ; <nl> - for ( const MultikeyPathInfo & path : txnParticipant - > getUncommittedMultikeyPathInfos ( ) ) { <nl> + for ( const MultikeyPathInfo & path : txnParticipant . getUncommittedMultikeyPathInfos ( ) ) { <nl> if ( path . nss = = NamespaceString ( _ns ) & & path . indexName = = _descriptor - > indexName ( ) ) { <nl> MultikeyPathTracker : : mergeMultikeyPaths ( & ret , path . multikeyPaths ) ; <nl> } <nl> void IndexCatalogEntryImpl : : setMultikey ( OperationContext * opCtx , <nl> <nl> / / Keep multikey changes in memory to correctly service later reads using this index . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> - txnParticipant - > addUncommittedMultikeyPathInfo ( <nl> + if ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> + txnParticipant . addUncommittedMultikeyPathInfo ( <nl> MultikeyPathInfo { _collection - > ns ( ) , _descriptor - > indexName ( ) , std : : move ( paths ) } ) ; <nl> } <nl> } <nl> mmm a / src / mongo / db / commands / find_and_modify . cpp <nl> ppp b / src / mongo / db / commands / find_and_modify . cpp <nl> class CmdFindAndModify : public BasicCommand { <nl> maybeDisableValidation . emplace ( opCtx ) ; <nl> <nl> const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - const auto inTransaction = txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + const auto inTransaction = txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ; <nl> uassert ( 50781 , <nl> str : : stream ( ) < < " Cannot write to system collection " < < nsString . ns ( ) <nl> < < " within a transaction . " , <nl> class CmdFindAndModify : public BasicCommand { <nl> const auto stmtId = 0 ; <nl> if ( opCtx - > getTxnNumber ( ) & & ! inTransaction ) { <nl> const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( auto entry = txnParticipant - > checkStatementExecuted ( stmtId ) ) { <nl> + if ( auto entry = txnParticipant . checkStatementExecuted ( opCtx , stmtId ) ) { <nl> RetryableWritesStats : : get ( opCtx ) - > incrementRetriedCommandsCount ( ) ; <nl> RetryableWritesStats : : get ( opCtx ) - > incrementRetriedStatementsCount ( ) ; <nl> parseOplogEntryForFindAndModify ( opCtx , args , * entry , & result ) ; <nl> mmm a / src / mongo / db / commands / find_cmd . cpp <nl> ppp b / src / mongo / db / commands / find_cmd . cpp <nl> class FindCmd final : public Command { <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " It is illegal to open a tailable cursor in a transaction " , <nl> ! txnParticipant | | <nl> - ! ( txnParticipant - > inMultiDocumentTransaction ( ) & & qr - > isTailable ( ) ) ) ; <nl> + ! ( txnParticipant . inMultiDocumentTransaction ( ) & & qr - > isTailable ( ) ) ) ; <nl> <nl> uassert ( ErrorCodes : : OperationNotSupportedInTransaction , <nl> " The ' readOnce ' option is not supported within a transaction . " , <nl> - ! txnParticipant | | <nl> - ! txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) | | <nl> + ! txnParticipant | | ! txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) | | <nl> ! qr - > isReadOnce ( ) ) ; <nl> <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> mmm a / src / mongo / db / commands / run_aggregate . cpp <nl> ppp b / src / mongo / db / commands / run_aggregate . cpp <nl> boost : : intrusive_ptr < ExpressionContext > makeExpressionContext ( <nl> expCtx - > tempDir = storageGlobalParams . dbpath + " / _tmp " ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> expCtx - > inMultiDocumentTransaction = <nl> - txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> return expCtx ; <nl> } <nl> Status runAggregate ( OperationContext * opCtx , <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> / / If we are in a multi - document transaction , we intercept the ' readConcern ' <nl> / / assertion in order to provide a more descriptive error message and code . <nl> - if ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> return { ErrorCodes : : OperationNotSupportedInTransaction , <nl> ex . toStatus ( " Operation not permitted in transaction " ) . reason ( ) } ; <nl> } <nl> mmm a / src / mongo / db / commands / txn_cmds . cpp <nl> ppp b / src / mongo / db / commands / txn_cmds . cpp <nl> class CmdCommitTxn : public BasicCommand { <nl> < < opCtx - > getTxnNumber ( ) < < " on session " < < opCtx - > getLogicalSessionId ( ) - > toBSON ( ) ; <nl> <nl> / / commitTransaction is retryable . <nl> - if ( txnParticipant - > transactionIsCommitted ( ) ) { <nl> + if ( txnParticipant . transactionIsCommitted ( ) ) { <nl> / / We set the client last op to the last optime observed by the system to ensure that <nl> / / we wait for the specified write concern on an optime greater than or equal to the <nl> / / commit oplog entry . <nl> class CmdCommitTxn : public BasicCommand { <nl> <nl> uassert ( ErrorCodes : : NoSuchTransaction , <nl> " Transaction isn ' t in progress " , <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> CurOpFailpointHelpers : : waitWhileFailPointEnabled ( <nl> & hangBeforeCommitingTxn , opCtx , " hangBeforeCommitingTxn " ) ; <nl> class CmdCommitTxn : public BasicCommand { <nl> auto optionalCommitTimestamp = cmd . getCommitTimestamp ( ) ; <nl> if ( optionalCommitTimestamp ) { <nl> / / commitPreparedTransaction will throw if the transaction is not prepared . <nl> - txnParticipant - > commitPreparedTransaction ( opCtx , optionalCommitTimestamp . get ( ) , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx , optionalCommitTimestamp . get ( ) , { } ) ; <nl> } else { <nl> / / commitUnpreparedTransaction will throw if the transaction is prepared . <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ) ; <nl> } <nl> if ( MONGO_FAIL_POINT ( participantReturnNetworkErrorForCommitAfterExecutingCommitLogic ) ) { <nl> uasserted ( ErrorCodes : : HostUnreachable , <nl> class CmdAbortTxn : public BasicCommand { <nl> <nl> uassert ( ErrorCodes : : NoSuchTransaction , <nl> " Transaction isn ' t in progress " , <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> CurOpFailpointHelpers : : waitWhileFailPointEnabled ( <nl> & hangBeforeAbortingTxn , opCtx , " hangBeforeAbortingTxn " ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ) ; <nl> <nl> if ( MONGO_FAIL_POINT ( participantReturnNetworkErrorForAbortAfterExecutingAbortLogic ) ) { <nl> uasserted ( ErrorCodes : : HostUnreachable , <nl> mmm a / src / mongo / db / commands / write_commands / write_commands . cpp <nl> ppp b / src / mongo / db / commands / write_commands / write_commands . cpp <nl> class WriteCommand : : InvocationBase : public CommandInvocation { <nl> <nl> void _transactionChecks ( OperationContext * opCtx ) const { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( ! txnParticipant | | ! txnParticipant - > inMultiDocumentTransaction ( ) ) <nl> + if ( ! txnParticipant | | ! txnParticipant . inMultiDocumentTransaction ( ) ) <nl> return ; <nl> uassert ( 50791 , <nl> str : : stream ( ) < < " Cannot write to system collection " < < ns ( ) . toString ( ) <nl> mmm a / src / mongo / db / db_raii . cpp <nl> ppp b / src / mongo / db / db_raii . cpp <nl> LockMode getLockModeForQuery ( OperationContext * opCtx , const boost : : optional < Name <nl> <nl> / / Use IX locks for autocommit : false multi - statement transactions ; otherwise , use IS locks . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> uassert ( 51071 , <nl> " Cannot query system . views within a transaction " , <nl> ! nss | | ! nss - > isSystemDotViews ( ) ) ; <nl> mmm a / src / mongo / db / kill_sessions_local . cpp <nl> ppp b / src / mongo / db / kill_sessions_local . cpp <nl> void killSessionsAction ( <nl> void killSessionsAbortUnpreparedTransactions ( OperationContext * opCtx , <nl> const SessionKiller : : Matcher & matcher , <nl> ErrorCodes : : Error reason ) { <nl> - killSessionsAction ( <nl> - opCtx , <nl> - matcher , <nl> - [ ] ( const ObservableSession & session ) { <nl> - return ! TransactionParticipant : : get ( session . get ( ) ) - > transactionIsPrepared ( ) ; <nl> - } , <nl> - [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> - TransactionParticipant : : get ( session . get ( ) ) - > abortArbitraryTransaction ( ) ; <nl> - } , <nl> - reason ) ; <nl> + killSessionsAction ( opCtx , <nl> + matcher , <nl> + [ ] ( const ObservableSession & session ) { <nl> + return ! TransactionParticipant : : get ( session ) . transactionIsPrepared ( ) ; <nl> + } , <nl> + [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> + TransactionParticipant : : get ( session ) . abortTransactionIfNotPrepared ( <nl> + opCtx ) ; <nl> + } , <nl> + reason ) ; <nl> } <nl> <nl> SessionKiller : : Result killSessionsLocal ( OperationContext * opCtx , <nl> void killAllExpiredTransactions ( OperationContext * opCtx ) { <nl> [ when = opCtx - > getServiceContext ( ) - > getPreciseClockSource ( ) - > now ( ) ] ( <nl> const ObservableSession & session ) { <nl> <nl> - return TransactionParticipant : : get ( session . get ( ) ) - > expired ( ) ; <nl> + return TransactionParticipant : : get ( session ) . expiredAsOf ( when ) ; <nl> } , <nl> [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> - auto txnParticipant = TransactionParticipant : : get ( session . get ( ) ) ; <nl> - <nl> - LOG ( 0 ) <nl> - < < " Aborting transaction with txnNumber " < < txnParticipant - > getActiveTxnNumber ( ) <nl> + auto txnParticipant = TransactionParticipant : : get ( session ) ; <nl> + log ( ) <nl> + < < " Aborting transaction with txnNumber " < < txnParticipant . getActiveTxnNumber ( ) <nl> < < " on session " < < session . getSessionId ( ) . getId ( ) <nl> < < " because it has been running for longer than ' transactionLifetimeLimitSeconds ' " ; <nl> - <nl> - / / The try / catch block below is necessary because expiredAsOf ( ) in the filterFn above <nl> - / / could return true for expired , but unprepared transaction , but by the time we get to <nl> - / / actually kill it , the participant could theoretically become prepared ( being under <nl> - / / the SessionCatalog mutex doesn ' t prevent the concurrently running thread from doing <nl> - / / preparing the participant ) . <nl> - / / <nl> - / / Then when the execution reaches the killSessionFn , it would find the transaction is <nl> - / / prepared and not allowed to be killed , which would cause the exception below <nl> - try { <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - } catch ( const DBException & ex ) { <nl> - / / TODO ( schwerin ) : Can we catch a more specific exception ? <nl> - warning ( ) < < " May have failed to abort expired transaction on session " <nl> - < < session . getSessionId ( ) . getId ( ) < < " due to " < < redact ( ex . toStatus ( ) ) ; <nl> - } <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ) ; <nl> } , <nl> ErrorCodes : : ExceededTimeLimit ) ; <nl> } <nl> void killSessionsLocalShutdownAllTransactions ( OperationContext * opCtx ) { <nl> matcherAllSessions , <nl> [ ] ( const ObservableSession & ) { return true ; } , <nl> [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> - TransactionParticipant : : get ( session . get ( ) ) - > shutdown ( ) ; <nl> + TransactionParticipant : : get ( session ) . shutdown ( opCtx ) ; <nl> } , <nl> ErrorCodes : : InterruptedAtShutdown ) ; <nl> } <nl> void killSessionsLocalShutdownAllTransactions ( OperationContext * opCtx ) { <nl> void killSessionsAbortAllPreparedTransactions ( OperationContext * opCtx ) { <nl> SessionKiller : : Matcher matcherAllSessions ( <nl> KillAllSessionsByPatternSet { makeKillAllSessionsByPattern ( opCtx ) } ) ; <nl> - killSessionsAction ( <nl> - opCtx , <nl> - matcherAllSessions , <nl> - [ ] ( const ObservableSession & session ) { <nl> - / / Filter for sessions that have a prepared transaction . <nl> - return TransactionParticipant : : get ( session . get ( ) ) - > transactionIsPrepared ( ) ; <nl> - } , <nl> - [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> - / / Abort the prepared transaction and invalidate the session it is <nl> - / / associated with . <nl> - TransactionParticipant : : get ( session . get ( ) ) - > abortPreparedTransactionForRollback ( ) ; <nl> - } ) ; <nl> + killSessionsAction ( opCtx , <nl> + matcherAllSessions , <nl> + [ ] ( const ObservableSession & session ) { <nl> + / / Filter for sessions that have a prepared transaction . <nl> + return TransactionParticipant : : get ( session ) . transactionIsPrepared ( ) ; <nl> + } , <nl> + [ ] ( OperationContext * opCtx , const SessionToKill & session ) { <nl> + / / Abort the prepared transaction and invalidate the session it is <nl> + / / associated with . <nl> + TransactionParticipant : : get ( session ) . abortPreparedTransactionForRollback ( <nl> + opCtx ) ; <nl> + } ) ; <nl> } <nl> <nl> void yieldLocksForPreparedTransactions ( OperationContext * opCtx ) { <nl> void yieldLocksForPreparedTransactions ( OperationContext * opCtx ) { <nl> / / to yield their locks . <nl> SessionKiller : : Matcher matcherAllSessions ( <nl> KillAllSessionsByPatternSet { makeKillAllSessionsByPattern ( newOpCtx . get ( ) ) } ) ; <nl> - killSessionsAction ( <nl> - newOpCtx . get ( ) , <nl> - matcherAllSessions , <nl> - [ ] ( const ObservableSession & session ) { <nl> - return TransactionParticipant : : get ( session . get ( ) ) - > transactionIsPrepared ( ) ; <nl> - } , <nl> - [ ] ( OperationContext * killerOpCtx , const SessionToKill & session ) { <nl> - auto const txnParticipant = TransactionParticipant : : get ( session . get ( ) ) ; <nl> - / / Yield locks for prepared transactions . <nl> - / / When scanning and killing operations , all prepared transactions are included in the <nl> - / / list . Even though new sessions may be created after the scan , none of them can become <nl> - / / prepared during stepdown , since the RSTL has been enqueued , preventing any new <nl> - / / writes . <nl> - if ( txnParticipant - > transactionIsPrepared ( ) ) { <nl> - LOG ( 3 ) < < " Yielding locks of prepared transaction . SessionId : " <nl> - < < session . getSessionId ( ) . getId ( ) <nl> - < < " TxnNumber : " < < txnParticipant - > getActiveTxnNumber ( ) ; <nl> - txnParticipant - > refreshLocksForPreparedTransaction ( killerOpCtx , true ) ; <nl> - } <nl> - } ) ; <nl> + killSessionsAction ( newOpCtx . get ( ) , <nl> + matcherAllSessions , <nl> + [ ] ( const ObservableSession & session ) { <nl> + return TransactionParticipant : : get ( session ) . transactionIsPrepared ( ) ; <nl> + } , <nl> + [ ] ( OperationContext * killerOpCtx , const SessionToKill & session ) { <nl> + auto txnParticipant = TransactionParticipant : : get ( session ) ; <nl> + / / Yield locks for prepared transactions . <nl> + / / When scanning and killing operations , all prepared transactions are <nl> + / / included in the <nl> + / / list . Even though new sessions may be created after the scan , none of <nl> + / / them can become <nl> + / / prepared during stepdown , since the RSTL has been enqueued , preventing <nl> + / / any new <nl> + / / writes . <nl> + if ( txnParticipant . transactionIsPrepared ( ) ) { <nl> + LOG ( 3 ) < < " Yielding locks of prepared transaction . SessionId : " <nl> + < < session . getSessionId ( ) . getId ( ) <nl> + < < " TxnNumber : " < < txnParticipant . getActiveTxnNumber ( ) ; <nl> + txnParticipant . refreshLocksForPreparedTransaction ( killerOpCtx , true ) ; <nl> + } <nl> + } ) ; <nl> } <nl> <nl> } / / namespace mongo <nl> mmm a / src / mongo / db / op_observer_impl . cpp <nl> ppp b / src / mongo / db / op_observer_impl . cpp <nl> void onWriteOpCompleted ( OperationContext * opCtx , <nl> if ( lastStmtIdWriteOpTime . isNull ( ) ) <nl> return ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> if ( ! txnParticipant ) <nl> return ; <nl> <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( opCtx , <nl> - * opCtx - > getTxnNumber ( ) , <nl> - std : : move ( stmtIdsWritten ) , <nl> - lastStmtIdWriteOpTime , <nl> - lastStmtIdWriteDate , <nl> - txnState ) ; <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( opCtx , <nl> + * opCtx - > getTxnNumber ( ) , <nl> + std : : move ( stmtIdsWritten ) , <nl> + lastStmtIdWriteOpTime , <nl> + lastStmtIdWriteDate , <nl> + txnState ) ; <nl> } <nl> <nl> / * * <nl> OpTimeBundle replLogUpdate ( OperationContext * opCtx , const OplogUpdateEntryArgs & <nl> if ( txnParticipant ) { <nl> sessionInfo . setSessionId ( * opCtx - > getLogicalSessionId ( ) ) ; <nl> sessionInfo . setTxnNumber ( * opCtx - > getTxnNumber ( ) ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> } <nl> <nl> OpTimeBundle opTimes ; <nl> OpTimeBundle replLogDelete ( OperationContext * opCtx , <nl> if ( txnParticipant ) { <nl> sessionInfo . setSessionId ( * opCtx - > getLogicalSessionId ( ) ) ; <nl> sessionInfo . setTxnNumber ( * opCtx - > getTxnNumber ( ) ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> } <nl> <nl> OpTimeBundle opTimes ; <nl> void OpObserverImpl : : onInserts ( OperationContext * opCtx , <nl> std : : vector < InsertStatement > : : const_iterator first , <nl> std : : vector < InsertStatement > : : const_iterator last , <nl> bool fromMigrate ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> const bool inMultiDocumentTransaction = txnParticipant & & opCtx - > writesAreReplicated ( ) & & <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> Date_t lastWriteDate ; <nl> <nl> void OpObserverImpl : : onInserts ( OperationContext * opCtx , <nl> } <nl> for ( auto iter = first ; iter ! = last ; iter + + ) { <nl> auto operation = OplogEntry : : makeInsertOperation ( nss , uuid , iter - > doc ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx , operation ) ; <nl> } <nl> } else { <nl> lastWriteDate = getWallClockTimeForOpLog ( opCtx ) ; <nl> void OpObserverImpl : : onUpdate ( OperationContext * opCtx , const OplogUpdateEntryArg <nl> return ; <nl> } <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> const bool inMultiDocumentTransaction = txnParticipant & & opCtx - > writesAreReplicated ( ) & & <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> OpTimeBundle opTime ; <nl> if ( inMultiDocumentTransaction ) { <nl> auto operation = OplogEntry : : makeUpdateOperation ( <nl> args . nss , args . uuid , args . updateArgs . update , args . updateArgs . criteria ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx , operation ) ; <nl> } else { <nl> opTime = replLogUpdate ( opCtx , args ) ; <nl> onWriteOpCompleted ( opCtx , <nl> void OpObserverImpl : : onDelete ( OperationContext * opCtx , <nl> auto & documentKey = documentKeyDecoration ( opCtx ) ; <nl> invariant ( ! documentKey . isEmpty ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> const bool inMultiDocumentTransaction = txnParticipant & & opCtx - > writesAreReplicated ( ) & & <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> OpTimeBundle opTime ; <nl> if ( inMultiDocumentTransaction ) { <nl> auto operation = <nl> OplogEntry : : makeDeleteOperation ( nss , uuid , deletedDoc ? deletedDoc . get ( ) : documentKey ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx , operation ) ; <nl> } else { <nl> opTime = replLogDelete ( opCtx , nss , uuid , stmtId , fromMigrate , deletedDoc ) ; <nl> onWriteOpCompleted ( opCtx , <nl> OpTimeBundle logApplyOpsForTransaction ( OperationContext * opCtx , <nl> sessionInfo . setSessionId ( * opCtx - > getLogicalSessionId ( ) ) ; <nl> sessionInfo . setTxnNumber ( * opCtx - > getTxnNumber ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> / / Until we support multiple oplog entries per transaction , prevOpTime should always be null . <nl> invariant ( oplogLink . prevOpTime . isNull ( ) ) ; <nl> <nl> void logCommitOrAbortForPreparedTransaction ( OperationContext * opCtx , <nl> sessionInfo . setSessionId ( * opCtx - > getLogicalSessionId ( ) ) ; <nl> sessionInfo . setTxnNumber ( * opCtx - > getTxnNumber ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> <nl> const StmtId stmtId ( 1 ) ; <nl> const auto wallClockTime = getWallClockTimeForOpLog ( opCtx ) ; <nl> void OpObserverImpl : : onTransactionPrepare ( OperationContext * opCtx , <nl> const OplogSlot & prepareOpTime , <nl> std : : vector < repl : : ReplOperation > & statements ) { <nl> invariant ( opCtx - > getTxnNumber ( ) ) ; <nl> - <nl> invariant ( ! prepareOpTime . opTime . isNull ( ) ) ; <nl> <nl> / / Don ' t write oplog entry on secondaries . <nl> void OpObserverImpl : : onTransactionAbort ( OperationContext * opCtx , <nl> return ; <nl> } <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> invariant ( txnParticipant ) ; <nl> <nl> if ( ! abortOplogEntryOpTime ) { <nl> - invariant ( ! txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + invariant ( ! txnParticipant . transactionIsCommitted ( ) ) ; <nl> return ; <nl> } <nl> <nl> mmm a / src / mongo / db / op_observer_impl_test . cpp <nl> ppp b / src / mongo / db / op_observer_impl_test . cpp <nl> class OpObserverSessionCatalogRollbackTest : public OpObserverTest { <nl> * statement id . <nl> * / <nl> void simulateSessionWrite ( OperationContext * opCtx , <nl> - TransactionParticipant * txnParticipant , <nl> + TransactionParticipant : : Participant txnParticipant , <nl> NamespaceString nss , <nl> TxnNumber txnNum , <nl> StmtId stmtId ) { <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx , txnNum , boost : : none , boost : : none ) ; <nl> <nl> { <nl> AutoGetCollection autoColl ( opCtx , nss , MODE_IX ) ; <nl> WriteUnitOfWork wuow ( opCtx ) ; <nl> auto opTime = repl : : OpTime ( Timestamp ( 10 , 1 ) , 1 ) ; / / Dummy timestamp . <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx , txnNum , { stmtId } , opTime , Date_t : : now ( ) , boost : : none ) ; <nl> wuow . commit ( ) ; <nl> } <nl> TEST_F ( OpObserverSessionCatalogRollbackTest , <nl> auto opCtx = cc ( ) . makeOperationContext ( ) ; <nl> opCtx - > setLogicalSessionId ( sessionId ) ; <nl> MongoDOperationContextSession ocs ( opCtx . get ( ) ) ; <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx . get ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx . get ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx . get ( ) ) ; <nl> <nl> / / Simulate a write occurring on that session <nl> simulateSessionWrite ( opCtx . get ( ) , txnParticipant , nss , txnNum , stmtId ) ; <nl> <nl> / / Check that the statement executed <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) ; <nl> } <nl> <nl> / / Because there are no sessions to rollback , the OpObserver should not invalidate the in - memory <nl> TEST_F ( OpObserverSessionCatalogRollbackTest , <nl> auto opCtx = cc ( ) . makeOperationContext ( ) ; <nl> opCtx - > setLogicalSessionId ( sessionId ) ; <nl> MongoDOperationContextSession ocs ( opCtx . get ( ) ) ; <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx . get ( ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx . get ( ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) ; <nl> } <nl> } <nl> <nl> class OpObserverTransactionTest : public OpObserverTest { <nl> opCtx ( ) - > setTxnNumber ( txnNum ( ) ) ; <nl> _sessionCheckout = std : : make_unique < MongoDOperationContextSession > ( opCtx ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , true ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , true ) ; <nl> } <nl> <nl> void tearDown ( ) override { <nl> class OpObserverTransactionTest : public OpObserverTest { <nl> ASSERT_EQ ( txnState ! = boost : : none , <nl> txnRecordObj . hasField ( SessionTxnRecord : : kStateFieldName ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( session ( ) ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> if ( ! opTime . isNull ( ) ) { <nl> ASSERT_EQ ( opTime , txnRecord . getLastWriteOpTime ( ) ) ; <nl> - ASSERT_EQ ( opTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + ASSERT_EQ ( opTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> } else { <nl> - ASSERT_EQ ( txnRecord . getLastWriteOpTime ( ) , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + ASSERT_EQ ( txnRecord . getLastWriteOpTime ( ) , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> } <nl> } <nl> <nl> TEST_F ( OpObserverLargeTransactionTest , TransactionTooLargeWhileCommitting ) { <nl> auto uuid = CollectionUUID : : gen ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> / / This size is crafted such that two operations of this size are not too big to fit in a single <nl> / / oplog entry , but two operations plus oplog overhead are too big to fit in a single oplog <nl> TEST_F ( OpObserverLargeTransactionTest , TransactionTooLargeWhileCommitting ) { <nl> BSON ( <nl> " _id " < < 0 < < " data " <nl> < < BSONBinData ( halfTransactionData . get ( ) , kHalfTransactionSize , BinDataGeneral ) ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> ASSERT_THROWS_CODE ( opObserver ( ) . onTransactionCommit ( <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) , <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) , <nl> AssertionException , <nl> ErrorCodes : : TransactionTooLarge ) ; <nl> } <nl> TEST_F ( OpObserverTransactionTest , TransactionalPrepareTest ) { <nl> auto uuid1 = CollectionUUID : : gen ( ) ; <nl> auto uuid2 = CollectionUUID : : gen ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> AutoGetCollection autoColl1 ( opCtx ( ) , nss1 , MODE_IX ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalPrepareTest ) { <nl> < < " x " ) ) ; <nl> opObserver ( ) . onDelete ( opCtx ( ) , nss1 , uuid1 , 0 , false , boost : : none ) ; <nl> <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> { <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> OplogSlot slot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , slot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , slot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > recoveryUnit ( ) - > setPrepareTimestamp ( slot . opTime . getTimestamp ( ) ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedCommitTest ) { <nl> < < " x " ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> std : : vector < InsertStatement > insert ; <nl> insert . emplace_back ( 0 , doc ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedCommitTest ) { <nl> AutoGetCollection autoColl ( opCtx ( ) , nss , MODE_IX ) ; <nl> opObserver ( ) . onInserts ( opCtx ( ) , nss , uuid , insert . begin ( ) , insert . end ( ) , false ) ; <nl> <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> const auto prepareSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> prepareTimestamp = prepareSlot . opTime . getTimestamp ( ) ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , prepareSlot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , prepareSlot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> <nl> commitSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> } <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedCommitTest ) { <nl> opCtx ( ) - > setWriteUnitOfWork ( nullptr ) ; <nl> opCtx ( ) - > lockState ( ) - > unsetMaxLockTimeout ( ) ; <nl> <nl> - txnParticipant - > transitionToCommittingWithPrepareforTest ( ) ; <nl> + txnParticipant . transitionToCommittingWithPrepareforTest ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionCommit ( <nl> opCtx ( ) , <nl> commitSlot , <nl> prepareTimestamp , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> <nl> repl : : OplogInterfaceLocal oplogInterface ( opCtx ( ) , NamespaceString : : kRsOplogNamespace . ns ( ) ) ; <nl> auto oplogIter = oplogInterface . makeIterator ( ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedAbortTest ) { <nl> < < " x " ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> std : : vector < InsertStatement > insert ; <nl> insert . emplace_back ( 0 , doc ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedAbortTest ) { <nl> AutoGetCollection autoColl ( opCtx ( ) , nss , MODE_IX ) ; <nl> opObserver ( ) . onInserts ( opCtx ( ) , nss , uuid , insert . begin ( ) , insert . end ( ) , false ) ; <nl> <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> const auto prepareSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , prepareSlot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , prepareSlot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> abortSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , TransactionalPreparedAbortTest ) { <nl> opCtx ( ) - > setWriteUnitOfWork ( nullptr ) ; <nl> opCtx ( ) - > lockState ( ) - > unsetMaxLockTimeout ( ) ; <nl> opObserver ( ) . onTransactionAbort ( opCtx ( ) , abortSlot ) ; <nl> - txnParticipant - > transitionToAbortedWithPrepareforTest ( ) ; <nl> + txnParticipant . transitionToAbortedWithPrepareforTest ( opCtx ( ) ) ; <nl> <nl> repl : : OplogInterfaceLocal oplogInterface ( opCtx ( ) , NamespaceString : : kRsOplogNamespace . ns ( ) ) ; <nl> auto oplogIter = oplogInterface . makeIterator ( ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalUnpreparedAbortTest ) { <nl> const NamespaceString nss ( " testDB " , " testColl " ) ; <nl> const auto uuid = CollectionUUID : : gen ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> std : : vector < InsertStatement > insert ; <nl> insert . emplace_back ( 0 , <nl> TEST_F ( OpObserverTransactionTest , TransactionalUnpreparedAbortTest ) { <nl> AutoGetCollection autoColl ( opCtx ( ) , nss , MODE_IX ) ; <nl> opObserver ( ) . onInserts ( opCtx ( ) , nss , uuid , insert . begin ( ) , insert . end ( ) , false ) ; <nl> <nl> - txnParticipant - > transitionToAbortedWithoutPrepareforTest ( ) ; <nl> + txnParticipant . transitionToAbortedWithoutPrepareforTest ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionAbort ( opCtx ( ) , boost : : none ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , TransactionalUnpreparedAbortTest ) { <nl> <nl> TEST_F ( OpObserverTransactionTest , PreparingEmptyTransactionLogsEmptyApplyOps ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> <nl> { <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> OplogSlot slot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , slot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , slot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > recoveryUnit ( ) - > setPrepareTimestamp ( slot . opTime . getTimestamp ( ) ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , PreparingEmptyTransactionLogsEmptyApplyOps ) { <nl> <nl> TEST_F ( OpObserverTransactionTest , PreparingTransactionWritesToTransactionTable ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> <nl> repl : : OpTime prepareOpTime ; <nl> { <nl> TEST_F ( OpObserverTransactionTest , PreparingTransactionWritesToTransactionTable ) <nl> OplogSlot slot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> prepareOpTime = slot . opTime ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , slot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , slot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > recoveryUnit ( ) - > setPrepareTimestamp ( slot . opTime . getTimestamp ( ) ) ; <nl> } <nl> <nl> ASSERT_EQ ( prepareOpTime . getTimestamp ( ) , opCtx ( ) - > recoveryUnit ( ) - > getPrepareTimestamp ( ) ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> assertTxnRecord ( txnNum ( ) , prepareOpTime , DurableTxnStateEnum : : kPrepared ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , AbortingUnpreparedTransactionDoesNotWriteToTransactionTable ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> opObserver ( ) . onTransactionAbort ( opCtx ( ) , boost : : none ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Abort the storage - transaction without calling the OpObserver . <nl> - txnParticipant - > shutdown ( ) ; <nl> + txnParticipant . shutdown ( opCtx ( ) ) ; <nl> <nl> assertNoTxnRecord ( ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , AbortingPreparedTransactionWritesToTransactionTable ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> OplogSlot abortSlot ; <nl> { <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> OplogSlot slot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , slot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , slot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > recoveryUnit ( ) - > setPrepareTimestamp ( slot . opTime . getTimestamp ( ) ) ; <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> abortSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , AbortingPreparedTransactionWritesToTransaction <nl> opCtx ( ) - > setWriteUnitOfWork ( nullptr ) ; <nl> opCtx ( ) - > lockState ( ) - > unsetMaxLockTimeout ( ) ; <nl> opObserver ( ) . onTransactionAbort ( opCtx ( ) , abortSlot ) ; <nl> - txnParticipant - > transitionToAbortedWithPrepareforTest ( ) ; <nl> + txnParticipant . transitionToAbortedWithPrepareforTest ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Abort the storage - transaction without calling the OpObserver . <nl> - txnParticipant - > shutdown ( ) ; <nl> + txnParticipant . shutdown ( opCtx ( ) ) ; <nl> <nl> assertTxnRecord ( txnNum ( ) , { } , DurableTxnStateEnum : : kAborted ) ; <nl> } <nl> TEST_F ( OpObserverTransactionTest , CommittingUnpreparedNonEmptyTransactionWritesT <nl> const NamespaceString nss ( " testDB " , " testColl " ) ; <nl> const auto uuid = CollectionUUID : : gen ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> std : : vector < InsertStatement > insert ; <nl> insert . emplace_back ( 0 , <nl> TEST_F ( OpObserverTransactionTest , CommittingUnpreparedNonEmptyTransactionWritesT <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > getWriteUnitOfWork ( ) - > commit ( ) ; <nl> <nl> assertTxnRecord ( txnNum ( ) , { } , DurableTxnStateEnum : : kCommitted ) ; <nl> TEST_F ( OpObserverTransactionTest , CommittingUnpreparedNonEmptyTransactionWritesT <nl> TEST_F ( OpObserverTransactionTest , <nl> CommittingUnpreparedEmptyTransactionDoesNotWriteToTransactionTable ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> opObserver ( ) . onTransactionCommit ( <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Abort the storage - transaction without calling the OpObserver . <nl> - txnParticipant - > shutdown ( ) ; <nl> + txnParticipant . shutdown ( opCtx ( ) ) ; <nl> <nl> assertNoTxnRecord ( ) ; <nl> } <nl> <nl> TEST_F ( OpObserverTransactionTest , CommittingPreparedTransactionWritesToTransactionTable ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> repl : : OpTime prepareOpTime ; <nl> { <nl> TEST_F ( OpObserverTransactionTest , CommittingPreparedTransactionWritesToTransacti <nl> OplogSlot slot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> prepareOpTime = slot . opTime ; <nl> opObserver ( ) . onTransactionPrepare ( <nl> - opCtx ( ) , slot , txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + opCtx ( ) , slot , txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> opCtx ( ) - > recoveryUnit ( ) - > setPrepareTimestamp ( slot . opTime . getTimestamp ( ) ) ; <nl> - txnParticipant - > transitionToPreparedforTest ( ) ; <nl> + txnParticipant . transitionToPreparedforTest ( opCtx ( ) ) ; <nl> } <nl> <nl> OplogSlot commitSlot = repl : : getNextOpTime ( opCtx ( ) ) ; <nl> TEST_F ( OpObserverTransactionTest , CommittingPreparedTransactionWritesToTransacti <nl> opCtx ( ) - > setWriteUnitOfWork ( nullptr ) ; <nl> opCtx ( ) - > lockState ( ) - > unsetMaxLockTimeout ( ) ; <nl> <nl> - txnParticipant - > transitionToCommittingWithPrepareforTest ( ) ; <nl> + txnParticipant . transitionToCommittingWithPrepareforTest ( opCtx ( ) ) ; <nl> opObserver ( ) . onTransactionCommit ( <nl> opCtx ( ) , <nl> commitSlot , <nl> prepareOpTime . getTimestamp ( ) , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> <nl> assertTxnRecord ( txnNum ( ) , commitOpTime , DurableTxnStateEnum : : kCommitted ) ; <nl> } <nl> TEST_F ( OpObserverTransactionTest , TransactionalInsertTest ) { <nl> auto uuid1 = CollectionUUID : : gen ( ) ; <nl> auto uuid2 = CollectionUUID : : gen ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> std : : vector < InsertStatement > inserts1 ; <nl> inserts1 . emplace_back ( 0 , <nl> TEST_F ( OpObserverTransactionTest , TransactionalInsertTest ) { <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> auto oplogEntryObj = getSingleOplogEntry ( opCtx ( ) ) ; <nl> checkCommonFields ( oplogEntryObj ) ; <nl> OplogEntry oplogEntry = assertGet ( OplogEntry : : parse ( oplogEntryObj ) ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalUpdateTest ) { <nl> auto uuid1 = CollectionUUID : : gen ( ) ; <nl> auto uuid2 = CollectionUUID : : gen ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " update " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " update " ) ; <nl> <nl> CollectionUpdateArgs updateArgs1 ; <nl> updateArgs1 . stmtId = 0 ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalUpdateTest ) { <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> auto oplogEntry = getSingleOplogEntry ( opCtx ( ) ) ; <nl> checkCommonFields ( oplogEntry ) ; <nl> auto o = oplogEntry . getObjectField ( " o " ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalDeleteTest ) { <nl> auto uuid2 = CollectionUUID : : gen ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " delete " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " delete " ) ; <nl> <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> AutoGetCollection autoColl1 ( opCtx ( ) , nss1 , MODE_IX ) ; <nl> TEST_F ( OpObserverTransactionTest , TransactionalDeleteTest ) { <nl> opCtx ( ) , <nl> boost : : none , <nl> boost : : none , <nl> - txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> + txnParticipant . retrieveCompletedTransactionOperations ( opCtx ( ) ) ) ; <nl> auto oplogEntry = getSingleOplogEntry ( opCtx ( ) ) ; <nl> checkCommonFields ( oplogEntry ) ; <nl> auto o = oplogEntry . getObjectField ( " o " ) ; <nl> mmm a / src / mongo / db / ops / write_ops_exec . cpp <nl> ppp b / src / mongo / db / ops / write_ops_exec . cpp <nl> void assertCanWrite_inlock ( OperationContext * opCtx , const NamespaceString & ns ) { <nl> <nl> void makeCollection ( OperationContext * opCtx , const NamespaceString & ns ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - auto inTransaction = txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + auto inTransaction = txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ; <nl> uassert ( ErrorCodes : : OperationNotSupportedInTransaction , <nl> str : : stream ( ) < < " Cannot create namespace " < < ns . ns ( ) <nl> < < " in multi - document transaction . " , <nl> bool handleError ( OperationContext * opCtx , <nl> } <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( txnParticipant & & txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) ) { <nl> + if ( txnParticipant & & txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) ) { <nl> if ( isTransientTransactionError ( <nl> ex . code ( ) , false / * hasWriteConcernError * / , false / * isCommitTransaction * / ) ) { <nl> / / Tell the client to try the whole txn again , by returning ok : 0 with errorLabels . <nl> throw ; <nl> } <nl> - <nl> / / If we are in a transaction , we must fail the whole batch . <nl> out - > results . emplace_back ( ex . toStatus ( ) ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ) ; <nl> return false ; <nl> } <nl> <nl> void insertDocuments ( OperationContext * opCtx , <nl> if ( supportsDocLocking ( ) ) { <nl> auto replCoord = repl : : ReplicationCoordinator : : get ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - auto inTransaction = txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + auto inTransaction = txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> if ( ! inTransaction & & ! replCoord - > isOplogDisabledFor ( opCtx , collection - > ns ( ) ) ) { <nl> / / Populate ' slots ' with new optimes for each insert . <nl> bool insertBatchAndHandleErrors ( OperationContext * opCtx , <nl> try { <nl> acquireCollection ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - auto inTxn = txnParticipant & & txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) ; <nl> + auto inTxn = txnParticipant & & txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) ; <nl> if ( ! collection - > getCollection ( ) - > isCapped ( ) & & ! inTxn & & batch . size ( ) > 1 ) { <nl> / / First try doing it all together . If all goes well , this is all we need to do . <nl> / / See Collection : : _insertDocuments for why we do all capped inserts one - at - a - time . <nl> WriteResult performInserts ( OperationContext * opCtx , <nl> / / transaction . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> invariant ( ! opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) | | <nl> - ( txnParticipant & & txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> + ( txnParticipant & & txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> auto & curOp = * CurOp : : get ( opCtx ) ; <nl> ON_BLOCK_EXIT ( [ & ] { <nl> / / This is the only part of finishCurOp we need to do for inserts because they reuse the <nl> WriteResult performInserts ( OperationContext * opCtx , <nl> } else { <nl> const auto stmtId = getStmtIdForWriteOp ( opCtx , wholeOp , stmtIdIndex + + ) ; <nl> if ( opCtx - > getTxnNumber ( ) ) { <nl> - if ( ! txnParticipant - > inMultiDocumentTransaction ( ) & & <nl> - txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) { <nl> + if ( ! txnParticipant . inMultiDocumentTransaction ( ) & & <nl> + txnParticipant . checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) { <nl> containsRetry = true ; <nl> RetryableWritesStats : : get ( opCtx ) - > incrementRetriedStatementsCount ( ) ; <nl> out . results . emplace_back ( makeWriteResultForInsertOrDeleteRetry ( ) ) ; <nl> static SingleWriteResult performSingleUpdateOpWithDupKeyRetry ( OperationContext * <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " Cannot use ( or request ) retryable writes with multi = true " , <nl> - ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) | | <nl> + ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) | | <nl> ! opCtx - > getTxnNumber ( ) | | ! op . getMulti ( ) ) ; <nl> <nl> UpdateRequest request ( ns ) ; <nl> WriteResult performUpdates ( OperationContext * opCtx , const write_ops : : Update & who <nl> / / transaction . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> invariant ( ! opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) | | <nl> - ( txnParticipant & & txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> + ( txnParticipant & & txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> uassertStatusOK ( userAllowedWriteNS ( wholeOp . getNamespace ( ) ) ) ; <nl> <nl> DisableDocumentValidationIfTrue docValidationDisabler ( <nl> WriteResult performUpdates ( OperationContext * opCtx , const write_ops : : Update & who <nl> for ( auto & & singleOp : wholeOp . getUpdates ( ) ) { <nl> const auto stmtId = getStmtIdForWriteOp ( opCtx , wholeOp , stmtIdIndex + + ) ; <nl> if ( opCtx - > getTxnNumber ( ) ) { <nl> - if ( ! txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> - if ( auto entry = txnParticipant - > checkStatementExecuted ( stmtId ) ) { <nl> + if ( ! txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> + if ( auto entry = txnParticipant . checkStatementExecuted ( opCtx , stmtId ) ) { <nl> containsRetry = true ; <nl> RetryableWritesStats : : get ( opCtx ) - > incrementRetriedStatementsCount ( ) ; <nl> out . results . emplace_back ( parseOplogEntryForUpdate ( * entry ) ) ; <nl> static SingleWriteResult performSingleDeleteOp ( OperationContext * opCtx , <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " Cannot use ( or request ) retryable writes with limit = 0 " , <nl> - ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) | | <nl> + ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) | | <nl> ! opCtx - > getTxnNumber ( ) | | ! op . getMulti ( ) ) ; <nl> <nl> globalOpCounters . gotDelete ( ) ; <nl> WriteResult performDeletes ( OperationContext * opCtx , const write_ops : : Delete & who <nl> / / transaction . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> invariant ( ! opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) | | <nl> - ( txnParticipant & & txnParticipant - > inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> + ( txnParticipant & & txnParticipant . inActiveOrKilledMultiDocumentTransaction ( ) ) ) ; <nl> uassertStatusOK ( userAllowedWriteNS ( wholeOp . getNamespace ( ) ) ) ; <nl> <nl> DisableDocumentValidationIfTrue docValidationDisabler ( <nl> WriteResult performDeletes ( OperationContext * opCtx , const write_ops : : Delete & who <nl> for ( auto & & singleOp : wholeOp . getDeletes ( ) ) { <nl> const auto stmtId = getStmtIdForWriteOp ( opCtx , wholeOp , stmtIdIndex + + ) ; <nl> if ( opCtx - > getTxnNumber ( ) ) { <nl> - if ( ! txnParticipant - > inMultiDocumentTransaction ( ) & & <nl> - txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) { <nl> + if ( ! txnParticipant . inMultiDocumentTransaction ( ) & & <nl> + txnParticipant . checkStatementExecutedNoOplogEntryFetch ( stmtId ) ) { <nl> containsRetry = true ; <nl> RetryableWritesStats : : get ( opCtx ) - > incrementRetriedStatementsCount ( ) ; <nl> out . results . emplace_back ( makeWriteResultForInsertOrDeleteRetry ( ) ) ; <nl> mmm a / src / mongo / db / pipeline / process_interface_shardsvr . cpp <nl> ppp b / src / mongo / db / pipeline / process_interface_shardsvr . cpp <nl> unique_ptr < Pipeline , PipelineDeleter > MongoInterfaceShardServer : : attachCursorSou <nl> / / cache , and attempt to do a network request while holding locks . <nl> / / TODO : SERVER - 39162 allow $ lookup in sharded transactions . <nl> auto txnParticipant = TransactionParticipant : : get ( expCtx - > opCtx ) ; <nl> - const bool inTxn = txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ; <nl> + const bool inTxn = txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ; <nl> <nl> const bool isSharded = [ & ] ( ) { <nl> if ( inTxn | | ! ShardingState : : get ( expCtx - > opCtx ) - > enabled ( ) ) { <nl> mmm a / src / mongo / db / pipeline / process_interface_standalone . cpp <nl> ppp b / src / mongo / db / pipeline / process_interface_standalone . cpp <nl> BSONObj MongoInterfaceStandalone : : _reportCurrentOpForClient ( <nl> <nl> if ( clientOpCtx ) { <nl> if ( auto txnParticipant = TransactionParticipant : : get ( clientOpCtx ) ) { <nl> - txnParticipant - > reportUnstashedState ( clientOpCtx , & builder ) ; <nl> + txnParticipant . reportUnstashedState ( clientOpCtx , & builder ) ; <nl> } <nl> <nl> / / Append lock stats before returning . <nl> void MongoInterfaceStandalone : : _reportCurrentOpsForIdleSessions ( OperationContext <nl> sessionCatalog - > scanSessions ( <nl> { std : : move ( sessionFilter ) } , <nl> [ & ] ( const ObservableSession & session ) { <nl> - auto op = TransactionParticipant : : get ( session . get ( ) ) - > reportStashedState ( ) ; <nl> + auto op = TransactionParticipant : : get ( session ) . reportStashedState ( opCtx ) ; <nl> if ( ! op . isEmpty ( ) ) { <nl> ops - > emplace_back ( op ) ; <nl> } <nl> mmm a / src / mongo / db / repl / apply_ops . cpp <nl> ppp b / src / mongo / db / repl / apply_ops . cpp <nl> Status _applyPrepareTransaction ( OperationContext * opCtx , <nl> MongoDOperationContextSessionWithoutRefresh sessionCheckout ( opCtx ) ; <nl> <nl> auto transaction = TransactionParticipant : : get ( opCtx ) ; <nl> - transaction - > unstashTransactionResources ( opCtx , " prepareTransaction " ) ; <nl> + transaction . unstashTransactionResources ( opCtx , " prepareTransaction " ) ; <nl> <nl> / / Apply the operations via applysOps functionality . <nl> int numApplied = 0 ; <nl> Status _applyPrepareTransaction ( OperationContext * opCtx , <nl> return status ; <nl> } <nl> invariant ( ! entry . getOpTime ( ) . isNull ( ) ) ; <nl> - transaction - > prepareTransaction ( opCtx , entry . getOpTime ( ) ) ; <nl> - transaction - > stashTransactionResources ( opCtx ) ; <nl> + transaction . prepareTransaction ( opCtx , entry . getOpTime ( ) ) ; <nl> + transaction . stashTransactionResources ( opCtx ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / repl / do_txn . cpp <nl> ppp b / src / mongo / db / repl / do_txn . cpp <nl> Status doTxn ( OperationContext * opCtx , <nl> BSONObjBuilder * result ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : InvalidOptions , " doTxn must be run within a transaction " , txnParticipant ) ; <nl> - invariant ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + invariant ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> invariant ( opCtx - > getWriteUnitOfWork ( ) ) ; <nl> uassert ( <nl> ErrorCodes : : InvalidOptions , " doTxn supports only CRUD opts . " , _areOpsCrudOnly ( doTxnCmd ) ) ; <nl> Status doTxn ( OperationContext * opCtx , <nl> <nl> numApplied = 0 ; <nl> uassertStatusOK ( _doTxn ( opCtx , dbName , doTxnCmd , & intermediateResult , & numApplied ) ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ) ; <nl> result - > appendElements ( intermediateResult . obj ( ) ) ; <nl> } catch ( const DBException & ex ) { <nl> - txnParticipant - > abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ) ; <nl> + txnParticipant . abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ) ; <nl> BSONArrayBuilder ab ; <nl> + + numApplied ; <nl> for ( int j = 0 ; j < numApplied ; j + + ) <nl> mmm a / src / mongo / db / repl / do_txn_test . cpp <nl> ppp b / src / mongo / db / repl / do_txn_test . cpp <nl> void DoTxnTest : : setUp ( ) { <nl> _ocs . emplace ( _opCtx . get ( ) ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , true ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " doTxn " ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , true ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " doTxn " ) ; <nl> } <nl> <nl> void DoTxnTest : : tearDown ( ) { <nl> mmm a / src / mongo / db / repl / mock_repl_coord_server_fixture . cpp <nl> ppp b / src / mongo / db / repl / mock_repl_coord_server_fixture . cpp <nl> void MockReplCoordServerFixture : : setUp ( ) { <nl> stdx : : make_unique < repl : : DropPendingCollectionReaper > ( repl : : StorageInterface : : get ( service ) ) ) ; <nl> } <nl> <nl> - void MockReplCoordServerFixture : : tearDown ( ) { <nl> - / / ServiceContextMongoDTest : : tearDown ( ) will try to create it ' s own opCtx , and it ' s not <nl> - / / allowed to have 2 present per client , so destroy this one . <nl> - _opCtx . reset ( ) ; <nl> - <nl> - ServiceContextMongoDTest : : tearDown ( ) ; <nl> - } <nl> - <nl> void MockReplCoordServerFixture : : insertOplogEntry ( const repl : : OplogEntry & entry ) { <nl> AutoGetCollection autoColl ( opCtx ( ) , NamespaceString : : kRsOplogNamespace , MODE_IX ) ; <nl> auto coll = autoColl . getCollection ( ) ; <nl> mmm a / src / mongo / db / repl / mock_repl_coord_server_fixture . h <nl> ppp b / src / mongo / db / repl / mock_repl_coord_server_fixture . h <nl> class StorageInterfaceMock ; <nl> class MockReplCoordServerFixture : public ServiceContextMongoDTest { <nl> public : <nl> void setUp ( ) override ; <nl> - void tearDown ( ) override ; <nl> <nl> / * * <nl> * Helper method for inserting new entries to the oplog . This completely bypasses <nl> mmm a / src / mongo / db / repl / oplog . cpp <nl> ppp b / src / mongo / db / repl / oplog . cpp <nl> std : : vector < OpTime > logInsertOps ( OperationContext * opCtx , <nl> if ( txnParticipant ) { <nl> sessionInfo . setSessionId ( * opCtx - > getLogicalSessionId ( ) ) ; <nl> sessionInfo . setTxnNumber ( * opCtx - > getTxnNumber ( ) ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> } <nl> <nl> auto timestamps = stdx : : make_unique < Timestamp [ ] > ( count ) ; <nl> mmm a / src / mongo / db / repl / replication_coordinator_impl . cpp <nl> ppp b / src / mongo / db / repl / replication_coordinator_impl . cpp <nl> Status ReplicationCoordinatorImpl : : checkCanServeReadsFor_UNSAFE ( OperationContext <nl> } <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - if ( txnParticipant & & txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + if ( txnParticipant & & txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> if ( ! _readWriteAbility - > canAcceptNonLocalWrites_UNSAFE ( ) & & ! getTestCommandsEnabled ( ) ) { <nl> return Status ( ErrorCodes : : NotMaster , <nl> " Multi - document transactions are only allowed on replica set primaries . " ) ; <nl> mmm a / src / mongo / db / repl / transaction_oplog_application . cpp <nl> ppp b / src / mongo / db / repl / transaction_oplog_application . cpp <nl> Status applyCommitTransaction ( OperationContext * opCtx , <nl> <nl> auto transaction = TransactionParticipant : : get ( opCtx ) ; <nl> invariant ( transaction ) ; <nl> - transaction - > unstashTransactionResources ( opCtx , " commitTransaction " ) ; <nl> - transaction - > commitPreparedTransaction ( <nl> + transaction . unstashTransactionResources ( opCtx , " commitTransaction " ) ; <nl> + transaction . commitPreparedTransaction ( <nl> opCtx , commitCommand . getCommitTimestamp ( ) , entry . getOpTime ( ) ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> Status applyAbortTransaction ( OperationContext * opCtx , <nl> MongoDOperationContextSessionWithoutRefresh sessionCheckout ( opCtx ) ; <nl> <nl> auto transaction = TransactionParticipant : : get ( opCtx ) ; <nl> - transaction - > unstashTransactionResources ( opCtx , " abortTransaction " ) ; <nl> - transaction - > abortActiveTransaction ( opCtx ) ; <nl> + transaction . unstashTransactionResources ( opCtx , " abortTransaction " ) ; <nl> + transaction . abortActiveTransaction ( opCtx ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / s / session_catalog_migration_destination . cpp <nl> ppp b / src / mongo / db / s / session_catalog_migration_destination . cpp <nl> ProcessOplogResult processSessionOplog ( const BSONObj & oplogBSON , <nl> opCtx - > setTxnNumber ( result . txnNum ) ; <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - txnParticipant - > beginOrContinue ( result . txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx , result . txnNum , boost : : none , boost : : none ) ; <nl> <nl> try { <nl> - if ( txnParticipant - > checkStatementExecuted ( stmtId ) ) { <nl> + if ( txnParticipant . checkStatementExecuted ( opCtx , stmtId ) ) { <nl> / / Skip the incoming statement because it has already been logged locally <nl> return lastResult ; <nl> } <nl> ProcessOplogResult processSessionOplog ( const BSONObj & oplogBSON , <nl> ? oplogEntry . getObject ( ) <nl> : BSON ( SessionCatalogMigrationDestination : : kSessionMigrateOplogTag < < 1 ) ) ; <nl> auto oplogLink = extractPrePostImageTs ( lastResult , oplogEntry ) ; <nl> - oplogLink . prevOpTime = txnParticipant - > getLastWriteOpTime ( ) ; <nl> + oplogLink . prevOpTime = txnParticipant . getLastWriteOpTime ( ) ; <nl> <nl> writeConflictRetry ( <nl> opCtx , <nl> ProcessOplogResult processSessionOplog ( const BSONObj & oplogBSON , <nl> / / Do not call onWriteOpCompletedOnPrimary if we inserted a pre / post image , because the <nl> / / next oplog will contain the real operation <nl> if ( ! result . isPrePostImage ) { <nl> - txnParticipant - > onMigrateCompletedOnPrimary ( <nl> + txnParticipant . onMigrateCompletedOnPrimary ( <nl> opCtx , result . txnNum , { stmtId } , oplogOpTime , * oplogEntry . getWallClockTime ( ) ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / s / session_catalog_migration_destination_test . cpp <nl> ppp b / src / mongo / db / s / session_catalog_migration_destination_test . cpp <nl> class SessionCatalogMigrationDestinationTest : public ShardServerTestFixture { <nl> opCtx - > setTxnNumber ( txnNum ) ; <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx , txnNum , boost : : none , boost : : none ) ; <nl> } <nl> <nl> void checkOplog ( const repl : : OplogEntry & originalOplog , const repl : : OplogEntry & oplogToCheck ) { <nl> class SessionCatalogMigrationDestinationTest : public ShardServerTestFixture { <nl> <nl> void checkStatementExecuted ( OperationContext * opCtx , TxnNumber txnNumber , StmtId stmtId ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - auto oplog = txnParticipant - > checkStatementExecuted ( stmtId ) ; <nl> + auto oplog = txnParticipant . checkStatementExecuted ( opCtx , stmtId ) ; <nl> ASSERT_TRUE ( oplog ) ; <nl> } <nl> <nl> class SessionCatalogMigrationDestinationTest : public ShardServerTestFixture { <nl> StmtId stmtId , <nl> const repl : : OplogEntry & expectedOplog ) { <nl> const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - auto oplog = txnParticipant - > checkStatementExecuted ( stmtId ) ; <nl> + auto oplog = txnParticipant . checkStatementExecuted ( opCtx , stmtId ) ; <nl> ASSERT_TRUE ( oplog ) ; <nl> checkOplogWithNestedOplog ( expectedOplog , * oplog ) ; <nl> } <nl> class SessionCatalogMigrationDestinationTest : public ShardServerTestFixture { <nl> innerOpCtx . get ( ) , insertBuilder . obj ( ) , true , true , true , true ) ; <nl> MongoDOperationContextSession sessionTxnState ( innerOpCtx . get ( ) ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( innerOpCtx . get ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * sessionInfo . getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( <nl> + innerOpCtx . get ( ) , * sessionInfo . getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> <nl> const auto reply = performInserts ( innerOpCtx . get ( ) , insertRequest ) ; <nl> ASSERT ( reply . results . size ( ) = = 1 ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithSameTxn ) { <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog3 , historyIter . next ( opCtx ) ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldOnlyStoreHistoryOfLatestTxn <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog3 , historyIter . next ( opCtx ) ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithSameTxnInSeparate <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog3 , historyIter . next ( opCtx ) ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithDifferentSession ) <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog1 , historyIter . next ( opCtx ) ) ; <nl> ASSERT_FALSE ( historyIter . hasNext ( ) ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithDifferentSession ) <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx2 . get ( ) ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog3 , historyIter . next ( opCtx2 . get ( ) ) ) ; <nl> <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldNotNestAlreadyNestedOplog ) <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplog ( oplog2 , historyIter . next ( opCtx ) ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldBeAbleToHandlePreImageFindA <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> <nl> auto nextOplog = historyIter . next ( opCtx ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldBeAbleToHandlePostImageFind <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> <nl> auto nextOplog = historyIter . next ( opCtx ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldBeAbleToHandleFindAndModify <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> <nl> auto nextOplog = historyIter . next ( opCtx ) ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OlderTxnShouldBeIgnored ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> auto oplog = historyIter . next ( opCtx ) ; <nl> ASSERT_BSONOBJ_EQ ( BSON ( " _id " <nl> TEST_F ( SessionCatalogMigrationDestinationTest , NewerTxnWriteShouldNotBeOverwritt <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> auto oplog = historyIter . next ( opCtx ) ; <nl> ASSERT_BSONOBJ_EQ ( BSON ( " _id " <nl> TEST_F ( SessionCatalogMigrationDestinationTest , <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog2 , historyIter . next ( opCtx ) ) ; <nl> <nl> TEST_F ( SessionCatalogMigrationDestinationTest , ShouldIgnoreAlreadyExecutedStatem <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplog3 , historyIter . next ( opCtx ) ) ; <nl> <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithIncompleteHistory <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplogEntries [ 2 ] , historyIter . next ( opCtx ) ) ; <nl> <nl> TEST_F ( SessionCatalogMigrationDestinationTest , OplogEntriesWithIncompleteHistory <nl> <nl> checkStatementExecuted ( opCtx , 2 , 23 , oplogEntries [ 0 ] ) ; <nl> checkStatementExecuted ( opCtx , 2 , 5 , oplogEntries [ 2 ] ) ; <nl> - ASSERT_THROWS ( txnParticipant - > checkStatementExecuted ( 38 ) , AssertionException ) ; <nl> + ASSERT_THROWS ( txnParticipant . checkStatementExecuted ( opCtx , 38 ) , AssertionException ) ; <nl> } <nl> <nl> TEST_F ( SessionCatalogMigrationDestinationTest , <nl> TEST_F ( SessionCatalogMigrationDestinationTest , <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> - txnParticipant - > beginOrContinue ( 3 , boost : : none , boost : : none ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ) ; <nl> + txnParticipant . beginOrContinue ( opCtx , 3 , boost : : none , boost : : none ) ; <nl> } <nl> <nl> OperationSessionInfo sessionInfo2 ; <nl> TEST_F ( SessionCatalogMigrationDestinationTest , <nl> setUpSessionWithTxn ( opCtx , * sessionInfo1 . getSessionId ( ) , 3 ) ; <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant1 = TransactionParticipant : : get ( opCtx ) ; <nl> - ASSERT ( txnParticipant1 - > getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> + ASSERT ( txnParticipant1 . getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> } <nl> <nl> / / Check session 2 was correctly updated <nl> TEST_F ( SessionCatalogMigrationDestinationTest , <nl> MongoDOperationContextSession ocs ( opCtx ) ; <nl> auto txnParticipant2 = TransactionParticipant : : get ( opCtx ) ; <nl> <nl> - TransactionHistoryIterator historyIter ( txnParticipant2 - > getLastWriteOpTime ( ) ) ; <nl> + TransactionHistoryIterator historyIter ( txnParticipant2 . getLastWriteOpTime ( ) ) ; <nl> ASSERT_TRUE ( historyIter . hasNext ( ) ) ; <nl> checkOplogWithNestedOplog ( oplogEntries [ 2 ] , historyIter . next ( opCtx ) ) ; <nl> <nl> mmm a / src / mongo / db / s / txn_two_phase_commit_cmds . cpp <nl> ppp b / src / mongo / db / s / txn_two_phase_commit_cmds . cpp <nl> class PrepareTransactionCmd : public TypedCommand < PrepareTransactionCmd > { <nl> " ' prepareTransaction ' is not supported for replica sets with arbiters " , <nl> ! replCoord - > setContainsArbiter ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : CommandFailed , <nl> " prepareTransaction must be run within a transaction " , <nl> txnParticipant ) ; <nl> class PrepareTransactionCmd : public TypedCommand < PrepareTransactionCmd > { <nl> <nl> uassert ( ErrorCodes : : NoSuchTransaction , <nl> " Transaction isn ' t in progress " , <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - if ( txnParticipant - > transactionIsPrepared ( ) ) { <nl> + if ( txnParticipant . transactionIsPrepared ( ) ) { <nl> auto & replClient = repl : : ReplClientInfo : : forClient ( opCtx - > getClient ( ) ) ; <nl> - auto prepareOpTime = txnParticipant - > getPrepareOpTime ( ) ; <nl> + auto prepareOpTime = txnParticipant . getPrepareOpTime ( ) ; <nl> <nl> / / Set the client optime to be prepareOpTime if it ' s not already later than <nl> / / prepareOpTime . This ensures that we wait for writeConcern and that prepareOpTime <nl> class PrepareTransactionCmd : public TypedCommand < PrepareTransactionCmd > { <nl> return PrepareTimestamp ( prepareOpTime . getTimestamp ( ) ) ; <nl> } <nl> <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx , { } ) ; <nl> if ( MONGO_FAIL_POINT ( <nl> participantReturnNetworkErrorForPrepareAfterExecutingPrepareLogic ) ) { <nl> uasserted ( ErrorCodes : : HostUnreachable , <nl> mmm a / src / mongo / db / service_entry_point_common . cpp <nl> ppp b / src / mongo / db / service_entry_point_common . cpp <nl> void appendClusterAndOperationTime ( OperationContext * opCtx , <nl> <nl> void invokeWithSessionCheckedOut ( OperationContext * opCtx , <nl> CommandInvocation * invocation , <nl> - TransactionParticipant * txnParticipant , <nl> + TransactionParticipant : : Participant txnParticipant , <nl> const OperationSessionInfoFromClient & sessionOptions , <nl> rpc : : ReplyBuilderInterface * replyBuilder ) { <nl> if ( ! opCtx - > getClient ( ) - > isInDirectClient ( ) ) { <nl> - txnParticipant - > beginOrContinue ( * sessionOptions . getTxnNumber ( ) , <nl> - sessionOptions . getAutocommit ( ) , <nl> - sessionOptions . getStartTransaction ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx , <nl> + * sessionOptions . getTxnNumber ( ) , <nl> + sessionOptions . getAutocommit ( ) , <nl> + sessionOptions . getStartTransaction ( ) ) ; <nl> / / Create coordinator if needed . If " startTransaction " is present , it must be true . <nl> if ( sessionOptions . getStartTransaction ( ) ) { <nl> / / If this shard has been selected as the coordinator , set up the coordinator state <nl> void invokeWithSessionCheckedOut ( OperationContext * opCtx , <nl> if ( sessionOptions . getCoordinator ( ) = = boost : : optional < bool > ( true ) ) { <nl> createTransactionCoordinator ( opCtx , * sessionOptions . getTxnNumber ( ) ) ; <nl> } <nl> - } else if ( txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + } else if ( txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> const auto & readConcernArgs = repl : : ReadConcernArgs : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " Only the first command in a transaction may specify a readConcern " , <nl> readConcernArgs . isEmpty ( ) ) ; <nl> } <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx , invocation - > definition ( ) - > getName ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx , invocation - > definition ( ) - > getName ( ) ) ; <nl> } <nl> <nl> auto guard = makeGuard ( [ & txnParticipant , opCtx ] { <nl> - txnParticipant - > abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ) ; <nl> + txnParticipant . abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ) ; <nl> } ) ; <nl> <nl> try { <nl> void invokeWithSessionCheckedOut ( OperationContext * opCtx , <nl> <nl> / / If this shard has completed an earlier statement for this transaction , it must already be <nl> / / in the transaction ' s participant list , so it is guaranteed to learn its outcome . <nl> - txnParticipant - > stashTransactionResources ( opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ) ; <nl> guard . dismiss ( ) ; <nl> throw ; <nl> } <nl> void invokeWithSessionCheckedOut ( OperationContext * opCtx , <nl> } <nl> <nl> / / Stash or commit the transaction when the command succeeds . <nl> - txnParticipant - > stashTransactionResources ( opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ) ; <nl> guard . dismiss ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / session . h <nl> ppp b / src / mongo / db / session . h <nl> class Session : public Decorable < Session > { <nl> / / A pointer back to the currently running operation on this Session , or nullptr if there <nl> / / is no operation currently running for the Session . <nl> / / <nl> - / / May be read by holders of the SessionCatalog mutex . May only be set when clear or cleared <nl> - / / when set , and the opCtx being set or cleared must have its client locked at the time . <nl> + / / This field is only safe to read or write while holding the SessionCatalog : : _mutex . In <nl> + / / practice , it is only used inside of the SessionCatalog itself . <nl> OperationContext * _checkoutOpCtx { nullptr } ; <nl> <nl> / / Counter indicating the number of times ObservableSession : : kill has been called on this <nl> mmm a / src / mongo / db / session_catalog . cpp <nl> ppp b / src / mongo / db / session_catalog . cpp <nl> SessionCatalog : : ScopedCheckedOutSession SessionCatalog : : _checkOutSession ( Operati <nl> return ! osession . currentOperation ( ) & & ! osession . _killed ( ) ; <nl> } ) ; <nl> <nl> - { <nl> - stdx : : lock_guard < Client > lockClient ( * opCtx - > getClient ( ) ) ; <nl> - sri - > session . _checkoutOpCtx = opCtx ; <nl> - } <nl> + sri - > session . _checkoutOpCtx = opCtx ; <nl> <nl> return ScopedCheckedOutSession ( <nl> * this , std : : move ( sri ) , boost : : none / * Not checked out for kill * / ) ; <nl> SessionCatalog : : SessionToKill SessionCatalog : : checkOutSessionForKill ( OperationCo <nl> return ! ObservableSession ( ul , sri - > session ) . currentOperation ( ) ; <nl> } ) ; <nl> <nl> - { <nl> - stdx : : lock_guard < Client > lockClient ( * opCtx - > getClient ( ) ) ; <nl> - sri - > session . _checkoutOpCtx = opCtx ; <nl> - } <nl> + sri - > session . _checkoutOpCtx = opCtx ; <nl> <nl> return SessionToKill ( ScopedCheckedOutSession ( * this , std : : move ( sri ) , std : : move ( killToken ) ) ) ; <nl> } <nl> void SessionCatalog : : _releaseSession ( std : : shared_ptr < SessionCatalog : : SessionRunt <nl> / / operation context ( meaning checked - out ) <nl> invariant ( _sessions [ sri - > session . getSessionId ( ) ] = = sri ) ; <nl> invariant ( sri - > session . _checkoutOpCtx ) ; <nl> - { <nl> - stdx : : lock_guard < Client > lockClient ( * sri - > session . _checkoutOpCtx - > getClient ( ) ) ; <nl> - sri - > session . _checkoutOpCtx = nullptr ; <nl> - } <nl> + sri - > session . _checkoutOpCtx = nullptr ; <nl> sri - > availableCondVar . notify_all ( ) ; <nl> <nl> if ( killToken ) { <nl> SessionCatalog : : KillToken ObservableSession : : kill ( ErrorCodes : : Error reason ) cons <nl> / / For currently checked - out sessions , interrupt the operation context so that the current owner <nl> / / can release the session <nl> if ( firstKiller & & _session - > _checkoutOpCtx ) { <nl> - stdx : : lock_guard < Client > lg ( * _session - > _checkoutOpCtx - > getClient ( ) ) ; <nl> - <nl> + invariant ( _clientLock ) ; <nl> const auto serviceContext = _session - > _checkoutOpCtx - > getServiceContext ( ) ; <nl> - serviceContext - > killOperation ( lg , _session - > _checkoutOpCtx , reason ) ; <nl> + serviceContext - > killOperation ( _clientLock , _session - > _checkoutOpCtx , reason ) ; <nl> } <nl> <nl> return SessionCatalog : : KillToken ( getSessionId ( ) ) ; <nl> mmm a / src / mongo / db / session_catalog . h <nl> ppp b / src / mongo / db / session_catalog . h <nl> class ObservableSession { <nl> / * * <nl> * Increments the number of " killers " for this session and returns a ' kill token ' to to be <nl> * passed later on to ' checkOutSessionForKill ' method of the SessionCatalog in order to permit <nl> - * the caller to execute any kill cleanup tasks . This token is later on passed to <nl> - * ' _markNotKilled ' in order to decrement the number of " killers " . <nl> + * the caller to execute any kill cleanup tasks . This token is later used to decrement the <nl> + * number of " killers " . <nl> * <nl> * Marking session as killed is an internal property only that will cause any further calls to <nl> * ' checkOutSession ' to block until ' checkOutSessionForKill ' is called the same number of times <nl> class ObservableSession { <nl> return { } ; <nl> } <nl> <nl> - ObservableSession ( WithLock wl , Session & session ) : _session ( & session ) { } <nl> + ObservableSession ( WithLock wl , Session & session ) <nl> + : _session ( & session ) , _clientLock ( _lockClientForSession ( std : : move ( wl ) , _session ) ) { } <nl> <nl> / * * <nl> * Returns whether ' kill ' has been called on this session . <nl> * / <nl> bool _killed ( ) const ; <nl> <nl> - / * * <nl> - * Used by the session catalog when checking a session back in after a call to ' kill ' . See the <nl> - * comments for ' kill for more details . <nl> - * / <nl> - void _markNotKilled ( WithLock sessionCatalogLock , SessionCatalog : : KillToken killToken ) ; <nl> - <nl> Session * _session ; <nl> + stdx : : unique_lock < Client > _clientLock ; <nl> } ; <nl> <nl> - <nl> / * * <nl> * Scoped object , which checks out the session specified in the passed operation context and stores <nl> * it for later access by the command . The session is installed at construction time and is removed <nl> mmm a / src / mongo / db / session_catalog_mongod . cpp <nl> ppp b / src / mongo / db / session_catalog_mongod . cpp <nl> void killSessionTokensFunction ( <nl> for ( auto & sessionKillToken : * sessionKillTokens ) { <nl> auto session = catalog - > checkOutSessionForKill ( opCtx , std : : move ( sessionKillToken ) ) ; <nl> <nl> - auto const txnParticipant = TransactionParticipant : : get ( session . get ( ) ) ; <nl> - txnParticipant - > invalidate ( ) ; <nl> + TransactionParticipant : : get ( session ) . invalidate ( opCtx ) ; <nl> } <nl> } ) ) ; <nl> } <nl> void MongoDSessionCatalog : : onStepUp ( OperationContext * opCtx ) { <nl> SessionKiller : : Matcher matcher ( <nl> KillAllSessionsByPatternSet { makeKillAllSessionsByPattern ( opCtx ) } ) ; <nl> catalog - > scanSessions ( matcher , [ & ] ( const ObservableSession & session ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( session . get ( ) ) ; <nl> - if ( ! txnParticipant - > inMultiDocumentTransaction ( ) ) { <nl> + const auto txnParticipant = TransactionParticipant : : get ( session ) ; <nl> + if ( ! txnParticipant . inMultiDocumentTransaction ( ) ) { <nl> sessionKillTokens - > emplace_back ( session . kill ( ) ) ; <nl> } <nl> <nl> - if ( txnParticipant - > transactionIsPrepared ( ) ) { <nl> + if ( txnParticipant . transactionIsPrepared ( ) ) { <nl> sessionIdToReacquireLocks . emplace_back ( session . getSessionId ( ) ) ; <nl> } <nl> } ) ; <nl> void MongoDSessionCatalog : : onStepUp ( OperationContext * opCtx ) { <nl> auto newOpCtx = cc ( ) . makeOperationContext ( ) ; <nl> newOpCtx - > setLogicalSessionId ( sessionId ) ; <nl> MongoDOperationContextSession ocs ( newOpCtx . get ( ) ) ; <nl> - auto txnParticipant = <nl> - TransactionParticipant : : get ( OperationContextSession : : get ( newOpCtx . get ( ) ) ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( newOpCtx . get ( ) ) ; <nl> LOG ( 3 ) < < " Restoring locks of prepared transaction . SessionId : " < < sessionId . getId ( ) <nl> - < < " TxnNumber : " < < txnParticipant - > getActiveTxnNumber ( ) ; <nl> - txnParticipant - > refreshLocksForPreparedTransaction ( newOpCtx . get ( ) , false ) ; <nl> + < < " TxnNumber : " < < txnParticipant . getActiveTxnNumber ( ) ; <nl> + txnParticipant . refreshLocksForPreparedTransaction ( newOpCtx . get ( ) , false ) ; <nl> } <nl> } <nl> <nl> MongoDOperationContextSession : : MongoDOperationContextSession ( OperationContext * o <nl> : _operationContextSession ( opCtx ) { <nl> invariant ( ! opCtx - > getClient ( ) - > isInDirectClient ( ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ) ; <nl> } <nl> <nl> MongoDOperationContextSession : : ~ MongoDOperationContextSession ( ) = default ; <nl> <nl> void MongoDOperationContextSession : : checkIn ( OperationContext * opCtx ) { <nl> if ( auto txnParticipant = TransactionParticipant : : get ( opCtx ) ) { <nl> - txnParticipant - > stashTransactionResources ( opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ) ; <nl> } <nl> <nl> OperationContextSession : : checkIn ( opCtx ) ; <nl> void MongoDOperationContextSession : : checkOut ( OperationContext * opCtx , const std : <nl> OperationContextSession : : checkOut ( opCtx ) ; <nl> <nl> if ( auto txnParticipant = TransactionParticipant : : get ( opCtx ) ) { <nl> - txnParticipant - > unstashTransactionResources ( opCtx , cmdName ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx , cmdName ) ; <nl> } <nl> } <nl> <nl> MongoDOperationContextSessionWithoutRefresh : : MongoDOperationContextSessionWithou <nl> invariant ( ! opCtx - > getClient ( ) - > isInDirectClient ( ) ) ; <nl> const auto clientTxnNumber = * opCtx - > getTxnNumber ( ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - txnParticipant - > beginOrContinueTransactionUnconditionally ( clientTxnNumber ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + txnParticipant . beginOrContinueTransactionUnconditionally ( opCtx , clientTxnNumber ) ; <nl> } <nl> <nl> MongoDOperationContextSessionWithoutRefresh : : ~ MongoDOperationContextSessionWithoutRefresh ( ) = <nl> mmm a / src / mongo / db / transaction_participant . cpp <nl> ppp b / src / mongo / db / transaction_participant . cpp <nl> MONGO_FAIL_POINT_DEFINE ( onPrimaryTransactionalWrite ) ; <nl> <nl> const BSONObj TransactionParticipant : : kDeadEndSentinel ( BSON ( " $ incompleteOplogHistory " < < 1 ) ) ; <nl> <nl> - TransactionParticipant : : TransactionParticipant ( ) = default ; <nl> <nl> - TransactionParticipant : : ~ TransactionParticipant ( ) = default ; <nl> + TransactionParticipant : : Observer : : Observer ( const ObservableSession & osession ) <nl> + : Observer ( & getTransactionParticipant ( osession . get ( ) ) ) { } <nl> <nl> - TransactionParticipant * TransactionParticipant : : get ( OperationContext * opCtx ) { <nl> - auto session = OperationContextSession : : get ( opCtx ) ; <nl> - if ( ! session ) { <nl> - return nullptr ; <nl> - } <nl> - <nl> - return get ( session ) ; <nl> - } <nl> + TransactionParticipant : : Participant : : Participant ( OperationContext * opCtx ) <nl> + : Observer ( [ opCtx ] ( ) - > TransactionParticipant * { <nl> + if ( auto session = OperationContextSession : : get ( opCtx ) ) { <nl> + return & getTransactionParticipant ( session ) ; <nl> + } <nl> + return nullptr ; <nl> + } ( ) ) { } <nl> <nl> - TransactionParticipant * TransactionParticipant : : get ( Session * session ) { <nl> - return & getTransactionParticipant ( session ) ; <nl> - } <nl> + TransactionParticipant : : Participant : : Participant ( const SessionToKill & session ) <nl> + : Observer ( & getTransactionParticipant ( session . get ( ) ) ) { } <nl> <nl> void TransactionParticipant : : performNoopWriteForNoSuchTransaction ( OperationContext * opCtx ) { <nl> repl : : ReplicationCoordinator * replCoord = <nl> void TransactionParticipant : : performNoopWriteForNoSuchTransaction ( OperationConte <nl> } <nl> } <nl> <nl> - const LogicalSessionId & TransactionParticipant : : _sessionId ( ) const { <nl> - const auto * owningSession = getTransactionParticipant . owner ( this ) ; <nl> + const LogicalSessionId & TransactionParticipant : : Observer : : _sessionId ( ) const { <nl> + const auto * owningSession = getTransactionParticipant . owner ( _tp ) ; <nl> return owningSession - > getSessionId ( ) ; <nl> } <nl> <nl> - OperationContext * TransactionParticipant : : _opCtx ( ) const { <nl> - const auto * owningSession = getTransactionParticipant . owner ( this ) ; <nl> - auto * opCtx = owningSession - > currentOperation_forTest ( ) ; <nl> - invariant ( opCtx ) ; <nl> - return opCtx ; <nl> - } <nl> - <nl> - void TransactionParticipant : : _beginOrContinueRetryableWrite ( WithLock wl , TxnNumber txnNumber ) { <nl> - if ( txnNumber > _activeTxnNumber ) { <nl> + void TransactionParticipant : : Participant : : _beginOrContinueRetryableWrite ( OperationContext * opCtx , <nl> + TxnNumber txnNumber ) { <nl> + if ( txnNumber > o ( ) . activeTxnNumber ) { <nl> / / New retryable write . <nl> - _setNewTxnNumber ( wl , txnNumber ) ; <nl> - _autoCommit = boost : : none ; <nl> + _setNewTxnNumber ( opCtx , txnNumber ) ; <nl> + p ( ) . autoCommit = boost : : none ; <nl> } else { <nl> / / Retrying a retryable write . <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " Must specify autocommit = false on all operations of a multi - statement transaction . " , <nl> - _txnState . isNone ( wl ) ) ; <nl> - invariant ( _autoCommit = = boost : : none ) ; <nl> + o ( ) . txnState . isNone ( ) ) ; <nl> + invariant ( p ( ) . autoCommit = = boost : : none ) ; <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : _continueMultiDocumentTransaction ( WithLock wl , TxnNumber txnNumber ) { <nl> + void TransactionParticipant : : Participant : : _continueMultiDocumentTransaction ( OperationContext * opCtx , <nl> + TxnNumber txnNumber ) { <nl> uassert ( ErrorCodes : : NoSuchTransaction , <nl> str : : stream ( ) <nl> < < " Given transaction number " <nl> < < txnNumber <nl> < < " does not match any in - progress transactions . The active transaction number is " <nl> - < < _activeTxnNumber , <nl> - txnNumber = = _activeTxnNumber & & ! _txnState . isNone ( wl ) ) ; <nl> + < < o ( ) . activeTxnNumber , <nl> + txnNumber = = o ( ) . activeTxnNumber & & ! o ( ) . txnState . isNone ( ) ) ; <nl> <nl> - if ( _txnState . isInProgress ( wl ) & & ! _txnResourceStash ) { <nl> + if ( o ( ) . txnState . isInProgress ( ) & & ! o ( ) . txnResourceStash ) { <nl> / / This indicates that the first command in the transaction failed but did not implicitly <nl> / / abort the transaction . It is not safe to continue the transaction , in particular because <nl> / / we have not saved the readConcern from the first statement of the transaction . Mark the <nl> / / transaction as active here , since _abortTransactionOnSession ( ) will assume we are <nl> / / aborting an active transaction since there are no stashed resources . <nl> - _transactionMetricsObserver . onUnstash ( <nl> - ServerTransactionsMetrics : : get ( getGlobalServiceContext ( ) ) , <nl> - getGlobalServiceContext ( ) - > getTickSource ( ) ) ; <nl> - _abortTransactionOnSession ( wl ) ; <nl> + { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onUnstash ( <nl> + ServerTransactionsMetrics : : get ( opCtx - > getServiceContext ( ) ) , <nl> + opCtx - > getServiceContext ( ) - > getTickSource ( ) ) ; <nl> + } <nl> + _abortTransactionOnSession ( opCtx ) ; <nl> <nl> uasserted ( ErrorCodes : : NoSuchTransaction , <nl> str : : stream ( ) < < " Transaction " < < txnNumber < < " has been aborted . " ) ; <nl> void TransactionParticipant : : _continueMultiDocumentTransaction ( WithLock wl , TxnN <nl> return ; <nl> } <nl> <nl> - void TransactionParticipant : : _beginMultiDocumentTransaction ( WithLock wl , TxnNumber txnNumber ) { <nl> + void TransactionParticipant : : Participant : : _beginMultiDocumentTransaction ( OperationContext * opCtx , <nl> + TxnNumber txnNumber ) { <nl> / / Aborts any in - progress txns . <nl> - _setNewTxnNumber ( wl , txnNumber ) ; <nl> - _autoCommit = false ; <nl> + _setNewTxnNumber ( opCtx , txnNumber ) ; <nl> + p ( ) . autoCommit = false ; <nl> <nl> - _txnState . transitionTo ( wl , TransactionState : : kInProgress ) ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kInProgress ) ; <nl> <nl> / / Start tracking various transactions metrics . <nl> / / <nl> / / We measure the start time in both microsecond and millisecond resolution . The TickSource <nl> / / provides microsecond resolution to record the duration of the transaction . The start " wall <nl> / / clock " time can be considered an approximation to the microsecond measurement . <nl> - auto now = getGlobalServiceContext ( ) - > getPreciseClockSource ( ) - > now ( ) ; <nl> - auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> + auto now = opCtx - > getServiceContext ( ) - > getPreciseClockSource ( ) - > now ( ) ; <nl> + auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> <nl> - _transactionExpireDate = now + Seconds ( transactionLifetimeLimitSeconds . load ( ) ) ; <nl> + o ( lk ) . transactionExpireDate = now + Seconds ( transactionLifetimeLimitSeconds . load ( ) ) ; <nl> <nl> - { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onStart ( <nl> - ServerTransactionsMetrics : : get ( getGlobalServiceContext ( ) ) , <nl> - * _autoCommit , <nl> - tickSource , <nl> - now , <nl> - * _transactionExpireDate ) ; <nl> - } <nl> - invariant ( _transactionOperations . empty ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onStart ( <nl> + ServerTransactionsMetrics : : get ( opCtx - > getServiceContext ( ) ) , <nl> + * p ( ) . autoCommit , <nl> + tickSource , <nl> + now , <nl> + * o ( ) . transactionExpireDate ) ; <nl> + invariant ( p ( ) . transactionOperations . empty ( ) ) ; <nl> } <nl> <nl> - void TransactionParticipant : : beginOrContinue ( TxnNumber txnNumber , <nl> - boost : : optional < bool > autocommit , <nl> - boost : : optional < bool > startTransaction ) { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - _checkValid ( lg ) ; <nl> - <nl> + void TransactionParticipant : : Participant : : beginOrContinue ( OperationContext * opCtx , <nl> + TxnNumber txnNumber , <nl> + boost : : optional < bool > autocommit , <nl> + boost : : optional < bool > startTransaction ) { <nl> uassert ( ErrorCodes : : TransactionTooOld , <nl> str : : stream ( ) < < " Cannot start transaction " < < txnNumber < < " on session " <nl> < < _sessionId ( ) <nl> < < " because a newer transaction " <nl> - < < _activeTxnNumber <nl> + < < o ( ) . activeTxnNumber <nl> < < " has already started . " , <nl> - txnNumber > = _activeTxnNumber ) ; <nl> + txnNumber > = o ( ) . activeTxnNumber ) ; <nl> <nl> / / Requests without an autocommit field are interpreted as retryable writes . They cannot specify <nl> / / startTransaction , which is verified earlier when parsing the request . <nl> if ( ! autocommit ) { <nl> invariant ( ! startTransaction ) ; <nl> - _beginOrContinueRetryableWrite ( lg , txnNumber ) ; <nl> + _beginOrContinueRetryableWrite ( opCtx , txnNumber ) ; <nl> return ; <nl> } <nl> <nl> void TransactionParticipant : : beginOrContinue ( TxnNumber txnNumber , <nl> invariant ( * autocommit = = false ) ; <nl> <nl> if ( ! startTransaction ) { <nl> - _continueMultiDocumentTransaction ( lg , txnNumber ) ; <nl> + _continueMultiDocumentTransaction ( opCtx , txnNumber ) ; <nl> return ; <nl> } <nl> <nl> void TransactionParticipant : : beginOrContinue ( TxnNumber txnNumber , <nl> / / as true , which is verified earlier , when parsing the request . <nl> invariant ( * startTransaction ) ; <nl> <nl> - if ( txnNumber = = _activeTxnNumber ) { <nl> + if ( txnNumber = = o ( ) . activeTxnNumber ) { <nl> / / Servers in a sharded cluster can start a new transaction at the active transaction number <nl> / / to allow internal retries by routers on re - targeting errors , like <nl> / / StaleShard / DatabaseVersion or SnapshotTooOld . <nl> void TransactionParticipant : : beginOrContinue ( TxnNumber txnNumber , <nl> str : : stream ( ) < < " Cannot start a transaction at given transaction number " <nl> < < txnNumber <nl> < < " a transaction with the same number is in state " <nl> - < < _txnState . toString ( ) , <nl> - _txnState . isInSet ( lg , restartableStates ) ) ; <nl> + < < o ( ) . txnState . toString ( ) , <nl> + o ( ) . txnState . isInSet ( restartableStates ) ) ; <nl> } <nl> <nl> - _beginMultiDocumentTransaction ( lg , txnNumber ) ; <nl> + _beginMultiDocumentTransaction ( opCtx , txnNumber ) ; <nl> } <nl> <nl> - void TransactionParticipant : : beginOrContinueTransactionUnconditionally ( TxnNumber txnNumber ) { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> + void TransactionParticipant : : Participant : : beginOrContinueTransactionUnconditionally ( <nl> + OperationContext * opCtx , TxnNumber txnNumber ) { <nl> <nl> / / We don ' t check or fetch any on - disk state , so treat the transaction as ' valid ' for the <nl> / / purposes of this method and continue the transaction unconditionally <nl> - _isValid = true ; <nl> + p ( ) . isValid = true ; <nl> <nl> - if ( _activeTxnNumber ! = txnNumber ) { <nl> - _beginMultiDocumentTransaction ( lg , txnNumber ) ; <nl> + if ( o ( ) . activeTxnNumber ! = txnNumber ) { <nl> + _beginMultiDocumentTransaction ( opCtx , txnNumber ) ; <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : _setSpeculativeTransactionOpTime ( <nl> - WithLock , OperationContext * opCtx , SpeculativeTransactionOpTime opTimeChoice ) { <nl> + void TransactionParticipant : : Participant : : _setSpeculativeTransactionOpTime ( <nl> + OperationContext * opCtx , SpeculativeTransactionOpTime opTimeChoice ) { <nl> repl : : ReplicationCoordinator * replCoord = <nl> - repl : : ReplicationCoordinator : : get ( opCtx - > getClient ( ) - > getServiceContext ( ) ) ; <nl> + repl : : ReplicationCoordinator : : get ( opCtx - > getServiceContext ( ) ) ; <nl> opCtx - > recoveryUnit ( ) - > setTimestampReadSource ( <nl> opTimeChoice = = SpeculativeTransactionOpTime : : kAllCommitted <nl> ? RecoveryUnit : : ReadSource : : kAllCommittedSnapshot <nl> void TransactionParticipant : : _setSpeculativeTransactionOpTime ( <nl> auto readTimestamp = repl : : StorageInterface : : get ( opCtx ) - > getPointInTimeReadTimestamp ( opCtx ) ; <nl> / / Transactions do not survive term changes , so combining " getTerm " here with the <nl> / / recovery unit timestamp does not cause races . <nl> - _speculativeTransactionReadOpTime = { readTimestamp , replCoord - > getTerm ( ) } ; <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onChooseReadTimestamp ( readTimestamp ) ; <nl> + p ( ) . speculativeTransactionReadOpTime = { readTimestamp , replCoord - > getTerm ( ) } ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onChooseReadTimestamp ( readTimestamp ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _setSpeculativeTransactionReadTimestamp ( WithLock , <nl> - OperationContext * opCtx , <nl> - Timestamp timestamp ) { <nl> + void TransactionParticipant : : Participant : : _setSpeculativeTransactionReadTimestamp ( <nl> + OperationContext * opCtx , Timestamp timestamp ) { <nl> / / Read concern code should have already set the timestamp on the recovery unit . <nl> invariant ( timestamp = = opCtx - > recoveryUnit ( ) - > getPointInTimeReadTimestamp ( ) ) ; <nl> <nl> repl : : ReplicationCoordinator * replCoord = <nl> repl : : ReplicationCoordinator : : get ( opCtx - > getClient ( ) - > getServiceContext ( ) ) ; <nl> opCtx - > recoveryUnit ( ) - > preallocateSnapshot ( ) ; <nl> - _speculativeTransactionReadOpTime = { timestamp , replCoord - > getTerm ( ) } ; <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onChooseReadTimestamp ( timestamp ) ; <nl> + p ( ) . speculativeTransactionReadOpTime = { timestamp , replCoord - > getTerm ( ) } ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onChooseReadTimestamp ( timestamp ) ; <nl> } <nl> <nl> TransactionParticipant : : OplogSlotReserver : : OplogSlotReserver ( OperationContext * opCtx ) <nl> TransactionParticipant : : OplogSlotReserver : : ~ OplogSlotReserver ( ) { <nl> replCoord - > attemptToAdvanceStableTimestamp ( ) ; <nl> } <nl> <nl> - TransactionParticipant : : TxnResources : : TxnResources ( OperationContext * opCtx , StashStyle stashStyle ) { <nl> - / / We must lock the Client to change the Locker on the OperationContext . <nl> - stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + TransactionParticipant : : TxnResources : : TxnResources ( WithLock wl , <nl> + OperationContext * opCtx , <nl> + StashStyle stashStyle ) noexcept { <nl> + / / We must hold the Client lock to change the Locker on the OperationContext . Hence the <nl> + / / WithLock . <nl> <nl> _ruState = opCtx - > getWriteUnitOfWork ( ) - > release ( ) ; <nl> opCtx - > setWriteUnitOfWork ( nullptr ) ; <nl> void TransactionParticipant : : TxnResources : : release ( OperationContext * opCtx ) { <nl> TransactionParticipant : : SideTransactionBlock : : SideTransactionBlock ( OperationContext * opCtx ) <nl> : _opCtx ( opCtx ) { <nl> if ( _opCtx - > getWriteUnitOfWork ( ) ) { <nl> + stdx : : lock_guard < Client > lk ( * _opCtx - > getClient ( ) ) ; <nl> _txnResources = TransactionParticipant : : TxnResources ( <nl> - _opCtx , TxnResources : : StashStyle : : kSideTransaction ) ; <nl> + lk , _opCtx , TxnResources : : StashStyle : : kSideTransaction ) ; <nl> } <nl> } <nl> <nl> TransactionParticipant : : SideTransactionBlock : : ~ SideTransactionBlock ( ) { <nl> if ( _txnResources ) { <nl> - / / Restore the transaction state onto ' _opCtx ' . <nl> _txnResources - > release ( _opCtx ) ; <nl> } <nl> } <nl> - void TransactionParticipant : : _stashActiveTransaction ( WithLock , OperationContext * opCtx ) { <nl> - if ( _inShutdown ) { <nl> + void TransactionParticipant : : Participant : : _stashActiveTransaction ( OperationContext * opCtx ) { <nl> + if ( p ( ) . inShutdown ) { <nl> return ; <nl> } <nl> <nl> - invariant ( _activeTxnNumber = = opCtx - > getTxnNumber ( ) ) ; <nl> + invariant ( o ( ) . activeTxnNumber = = opCtx - > getTxnNumber ( ) ) ; <nl> + <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> - _transactionMetricsObserver . onStash ( ServerTransactionsMetrics : : get ( opCtx ) , tickSource ) ; <nl> - _transactionMetricsObserver . onTransactionOperation ( <nl> + o ( lk ) . transactionMetricsObserver . onStash ( ServerTransactionsMetrics : : get ( opCtx ) , tickSource ) ; <nl> + o ( lk ) . transactionMetricsObserver . onTransactionOperation ( <nl> opCtx - > getClient ( ) , <nl> CurOp : : get ( opCtx ) - > debug ( ) . additiveMetrics , <nl> CurOp : : get ( opCtx ) - > debug ( ) . storageStats ) ; <nl> } <nl> <nl> - invariant ( ! _txnResourceStash ) ; <nl> + invariant ( ! o ( ) . txnResourceStash ) ; <nl> auto stashStyle = opCtx - > writesAreReplicated ( ) ? TxnResources : : StashStyle : : kPrimary <nl> : TxnResources : : StashStyle : : kSecondary ; <nl> - _txnResourceStash = TxnResources ( opCtx , stashStyle ) ; <nl> + o ( lk ) . txnResourceStash = TxnResources ( lk , opCtx , stashStyle ) ; <nl> } <nl> <nl> <nl> - void TransactionParticipant : : stashTransactionResources ( OperationContext * opCtx ) { <nl> + void TransactionParticipant : : Participant : : stashTransactionResources ( OperationContext * opCtx ) { <nl> if ( opCtx - > getClient ( ) - > isInDirectClient ( ) ) { <nl> return ; <nl> } <nl> - <nl> invariant ( opCtx - > getTxnNumber ( ) ) ; <nl> - stdx : : unique_lock < stdx : : mutex > lg ( _mutex ) ; <nl> - <nl> - / / Always check session ' s txnNumber , since it can be modified by migration , which does not <nl> - / / check out the session . We intentionally do not error if the transaction is aborted , since we <nl> - / / expect this function to be called at the end of the ' abortTransaction ' command . <nl> - _checkIsActiveTransaction ( lg , * opCtx - > getTxnNumber ( ) , false ) ; <nl> <nl> - if ( ! _txnState . inMultiDocumentTransaction ( lg ) ) { <nl> - / / Not in a multi - document transaction : nothing to do . <nl> - return ; <nl> + if ( o ( ) . txnState . inMultiDocumentTransaction ( ) ) { <nl> + _stashActiveTransaction ( opCtx ) ; <nl> } <nl> - <nl> - _stashActiveTransaction ( lg , opCtx ) ; <nl> } <nl> <nl> - void TransactionParticipant : : unstashTransactionResources ( OperationContext * opCtx , <nl> - const std : : string & cmdName ) { <nl> + void TransactionParticipant : : Participant : : _releaseTransactionResourcesToOpCtx ( <nl> + OperationContext * opCtx ) { <nl> + / / Transaction resources already exist for this transaction . Transfer them from the <nl> + / / stash to the operation context . <nl> + / / <nl> + / / Because TxnResources : : release must acquire the Client lock midway through , and because we <nl> + / / must hold the Client clock to mutate txnResourceStash , we jump through some hoops here to <nl> + / / move the TxnResources in txnResourceStash into a local variable that can be manipulated <nl> + / / without holding the Client lock . <nl> + [ & ] ( ) noexcept { <nl> + using std : : swap ; <nl> + boost : : optional < TxnResources > trs ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + swap ( trs , o ( lk ) . txnResourceStash ) ; <nl> + return std : : move ( * trs ) ; <nl> + } <nl> + ( ) . release ( opCtx ) ; <nl> + } <nl> + <nl> + void TransactionParticipant : : Participant : : unstashTransactionResources ( OperationContext * opCtx , <nl> + const std : : string & cmdName ) { <nl> invariant ( ! opCtx - > getClient ( ) - > isInDirectClient ( ) ) ; <nl> invariant ( opCtx - > getTxnNumber ( ) ) ; <nl> <nl> - { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - <nl> - _checkValid ( lg ) ; <nl> - _checkIsActiveTransaction ( lg , * opCtx - > getTxnNumber ( ) , false ) ; <nl> - <nl> - / / If this is not a multi - document transaction , there is nothing to unstash . <nl> - if ( _txnState . isNone ( lg ) ) { <nl> - invariant ( ! _txnResourceStash ) ; <nl> - return ; <nl> - } <nl> + / / If this is not a multi - document transaction , there is nothing to unstash . <nl> + if ( o ( ) . txnState . isNone ( ) ) { <nl> + invariant ( ! o ( ) . txnResourceStash ) ; <nl> + return ; <nl> + } <nl> <nl> - _checkIsCommandValidWithTxnState ( lg , * opCtx - > getTxnNumber ( ) , cmdName ) ; <nl> + _checkIsCommandValidWithTxnState ( * opCtx - > getTxnNumber ( ) , cmdName ) ; <nl> + if ( o ( ) . txnResourceStash ) { <nl> + _releaseTransactionResourcesToOpCtx ( opCtx ) ; <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> + o ( lg ) . transactionMetricsObserver . onUnstash ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> + opCtx - > getServiceContext ( ) - > getTickSource ( ) ) ; <nl> + return ; <nl> + } <nl> <nl> - if ( _txnResourceStash ) { <nl> - / / Transaction resources already exist for this transaction . Transfer them from the <nl> - / / stash to the operation context . <nl> - _txnResourceStash - > release ( opCtx ) ; <nl> - _txnResourceStash = boost : : none ; <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onUnstash ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> - opCtx - > getServiceContext ( ) - > getTickSource ( ) ) ; <nl> - return ; <nl> - } <nl> + / / If we have no transaction resources then we cannot be prepared . If we ' re not in progress , <nl> + / / we don ' t do anything else . <nl> + invariant ( ! o ( ) . txnState . isPrepared ( ) ) ; <nl> <nl> - / / If we have no transaction resources then we cannot be prepared . If we ' re not in progress , <nl> - / / we don ' t do anything else . <nl> - invariant ( ! _txnState . isPrepared ( lg ) ) ; <nl> + if ( ! o ( ) . txnState . isInProgress ( ) ) { <nl> + / / At this point we ' re either committed and this is a ' commitTransaction ' command , or we <nl> + / / are in the process of committing . <nl> + return ; <nl> + } <nl> <nl> - if ( ! _txnState . isInProgress ( lg ) ) { <nl> - / / At this point we ' re either committed and this is a ' commitTransaction ' command , or we <nl> - / / are in the process of committing . <nl> - return ; <nl> - } <nl> + / / All locks of transactions must be acquired inside the global WUOW so that we can <nl> + / / yield and restore all locks on state transition . Otherwise , we ' d have to remember <nl> + / / which locks are managed by WUOW . <nl> + invariant ( ! opCtx - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> - / / All locks of transactions must be acquired inside the global WUOW so that we can <nl> - / / yield and restore all locks on state transition . Otherwise , we ' d have to remember <nl> - / / which locks are managed by WUOW . <nl> - invariant ( ! opCtx - > lockState ( ) - > isLocked ( ) ) ; <nl> - <nl> - / / Stashed transaction resources do not exist for this in - progress multi - document <nl> - / / transaction . Set up the transaction resources on the opCtx . <nl> - opCtx - > setWriteUnitOfWork ( std : : make_unique < WriteUnitOfWork > ( opCtx ) ) ; <nl> - <nl> - / / If maxTransactionLockRequestTimeoutMillis is set , then we will ensure no <nl> - / / future lock request waits longer than maxTransactionLockRequestTimeoutMillis <nl> - / / to acquire a lock . This is to avoid deadlocks and minimize non - transaction <nl> - / / operation performance degradations . <nl> - auto maxTransactionLockMillis = maxTransactionLockRequestTimeoutMillis . load ( ) ; <nl> - if ( opCtx - > writesAreReplicated ( ) & & maxTransactionLockMillis > = 0 ) { <nl> - opCtx - > lockState ( ) - > setMaxLockTimeout ( Milliseconds ( maxTransactionLockMillis ) ) ; <nl> - } <nl> + / / Stashed transaction resources do not exist for this in - progress multi - document <nl> + / / transaction . Set up the transaction resources on the opCtx . <nl> + opCtx - > setWriteUnitOfWork ( std : : make_unique < WriteUnitOfWork > ( opCtx ) ) ; <nl> <nl> - / / On secondaries , max lock timeout must not be set . <nl> - invariant ( opCtx - > writesAreReplicated ( ) | | ! opCtx - > lockState ( ) - > hasMaxLockTimeout ( ) ) ; <nl> + / / If maxTransactionLockRequestTimeoutMillis is set , then we will ensure no <nl> + / / future lock request waits longer than maxTransactionLockRequestTimeoutMillis <nl> + / / to acquire a lock . This is to avoid deadlocks and minimize non - transaction <nl> + / / operation performance degradations . <nl> + auto maxTransactionLockMillis = maxTransactionLockRequestTimeoutMillis . load ( ) ; <nl> + if ( opCtx - > writesAreReplicated ( ) & & maxTransactionLockMillis > = 0 ) { <nl> + opCtx - > lockState ( ) - > setMaxLockTimeout ( Milliseconds ( maxTransactionLockMillis ) ) ; <nl> } <nl> <nl> + / / On secondaries , max lock timeout must not be set . <nl> + invariant ( opCtx - > writesAreReplicated ( ) | | ! opCtx - > lockState ( ) - > hasMaxLockTimeout ( ) ) ; <nl> + <nl> / / Storage engine transactions may be started in a lazy manner . By explicitly <nl> / / starting here we ensure that a point - in - time snapshot is established during the <nl> / / first operation of a transaction . <nl> void TransactionParticipant : : unstashTransactionResources ( OperationContext * opCtx <nl> / / not deadlock - safe to upgrade IS to IX . <nl> Lock : : GlobalLock ( opCtx , MODE_IX ) ; <nl> <nl> - { <nl> - / / Set speculative execution . This must be done after the global lock is acquired , because <nl> - / / we need to check that we are primary . <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - const auto & readConcernArgs = repl : : ReadConcernArgs : : get ( opCtx ) ; <nl> - / / TODO ( SERVER - 38203 ) : We cannot wait for write concern on secondaries , so we do not set the <nl> - / / speculative optime on secondaries either . This means that reads done in transactions on <nl> - / / secondaries will not wait for the read snapshot to become majority - committed . <nl> - repl : : ReplicationCoordinator * replCoord = <nl> - repl : : ReplicationCoordinator : : get ( opCtx - > getClient ( ) - > getServiceContext ( ) ) ; <nl> - if ( replCoord - > canAcceptWritesForDatabase ( <nl> - opCtx , NamespaceString : : kSessionTransactionsTableNamespace . db ( ) ) ) { <nl> - if ( readConcernArgs . getArgsAtClusterTime ( ) ) { <nl> - _setSpeculativeTransactionReadTimestamp ( <nl> - lg , opCtx , readConcernArgs . getArgsAtClusterTime ( ) - > asTimestamp ( ) ) ; <nl> - } else { <nl> - _setSpeculativeTransactionOpTime ( <nl> - lg , <nl> - opCtx , <nl> - readConcernArgs . getOriginalLevel ( ) = = <nl> - repl : : ReadConcernLevel : : kSnapshotReadConcern <nl> - ? SpeculativeTransactionOpTime : : kAllCommitted <nl> - : SpeculativeTransactionOpTime : : kLastApplied ) ; <nl> - } <nl> + / / Set speculative execution . This must be done after the global lock is acquired , because <nl> + / / we need to check that we are primary . <nl> + const auto & readConcernArgs = repl : : ReadConcernArgs : : get ( opCtx ) ; <nl> + / / TODO ( SERVER - 38203 ) : We cannot wait for write concern on secondaries , so we do not set the <nl> + / / speculative optime on secondaries either . This means that reads done in transactions on <nl> + / / secondaries will not wait for the read snapshot to become majority - committed . <nl> + repl : : ReplicationCoordinator * replCoord = <nl> + repl : : ReplicationCoordinator : : get ( opCtx - > getServiceContext ( ) ) ; <nl> + if ( replCoord - > canAcceptWritesForDatabase ( <nl> + opCtx , NamespaceString : : kSessionTransactionsTableNamespace . db ( ) ) ) { <nl> + if ( readConcernArgs . getArgsAtClusterTime ( ) ) { <nl> + _setSpeculativeTransactionReadTimestamp ( <nl> + opCtx , readConcernArgs . getArgsAtClusterTime ( ) - > asTimestamp ( ) ) ; <nl> } else { <nl> - opCtx - > recoveryUnit ( ) - > preallocateSnapshot ( ) ; <nl> + _setSpeculativeTransactionOpTime ( opCtx , <nl> + readConcernArgs . getOriginalLevel ( ) = = <nl> + repl : : ReadConcernLevel : : kSnapshotReadConcern <nl> + ? SpeculativeTransactionOpTime : : kAllCommitted <nl> + : SpeculativeTransactionOpTime : : kLastApplied ) ; <nl> } <nl> + } else { <nl> + opCtx - > recoveryUnit ( ) - > preallocateSnapshot ( ) ; <nl> } <nl> <nl> / / The Client lock must not be held when executing this failpoint as it will block currentOp <nl> void TransactionParticipant : : unstashTransactionResources ( OperationContext * opCtx <nl> } <nl> <nl> { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onUnstash ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> - opCtx - > getServiceContext ( ) - > getTickSource ( ) ) ; <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> + o ( lg ) . transactionMetricsObserver . onUnstash ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> + opCtx - > getServiceContext ( ) - > getTickSource ( ) ) ; <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : refreshLocksForPreparedTransaction ( OperationContext * opCtx , <nl> - bool yieldLocks ) { <nl> + void TransactionParticipant : : Participant : : refreshLocksForPreparedTransaction ( <nl> + OperationContext * opCtx , bool yieldLocks ) { <nl> / / The opCtx will be used to swap locks , so it cannot hold any lock . <nl> invariant ( ! opCtx - > lockState ( ) - > isRSTLLocked ( ) ) ; <nl> invariant ( ! opCtx - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> - stdx : : unique_lock < stdx : : mutex > lk ( _mutex ) ; <nl> <nl> / / The node must have txn resource . <nl> - invariant ( _txnResourceStash ) ; <nl> - invariant ( _txnState . isPrepared ( lk ) ) ; <nl> + invariant ( o ( ) . txnResourceStash ) ; <nl> + invariant ( o ( ) . txnState . isPrepared ( ) ) ; <nl> <nl> - / / Transfer the txn resource from the stash to the operation context . <nl> - _txnResourceStash - > release ( opCtx ) ; <nl> - _txnResourceStash = boost : : none ; <nl> + _releaseTransactionResourcesToOpCtx ( opCtx ) ; <nl> <nl> / / Snapshot transactions don ' t conflict with PBWM lock on both primary and secondary . <nl> invariant ( ! opCtx - > lockState ( ) - > shouldConflictWithSecondaryBatchApplication ( ) ) ; <nl> void TransactionParticipant : : refreshLocksForPreparedTransaction ( OperationContext <nl> / / Transfer the txn resource back from the operation context to the stash . <nl> auto stashStyle = <nl> yieldLocks ? TxnResources : : StashStyle : : kSecondary : TxnResources : : StashStyle : : kPrimary ; <nl> - _txnResourceStash = TxnResources ( opCtx , stashStyle ) ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnResourceStash = TxnResources ( lk , opCtx , stashStyle ) ; <nl> } <nl> <nl> - Timestamp TransactionParticipant : : prepareTransaction ( OperationContext * opCtx , <nl> - boost : : optional < repl : : OpTime > prepareOptime ) { <nl> - stdx : : unique_lock < stdx : : mutex > lk ( _mutex ) ; <nl> - <nl> - / / Always check session ' s txnNumber and ' _txnState ' , since they can be modified by <nl> - / / session kill and migration , which do not check out the session . <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> + Timestamp TransactionParticipant : : Participant : : prepareTransaction ( <nl> + OperationContext * opCtx , boost : : optional < repl : : OpTime > prepareOptime ) { <nl> <nl> auto abortGuard = makeGuard ( [ & ] { <nl> / / Prepare transaction on secondaries should always succeed . <nl> invariant ( ! prepareOptime ) ; <nl> <nl> - if ( lk . owns_lock ( ) ) { <nl> - lk . unlock ( ) ; <nl> - } <nl> - <nl> try { <nl> / / This shouldn ' t cause deadlocks with other prepared txns , because the acquisition <nl> / / of RSTL lock inside abortActiveTransaction will be no - op since we already have it . <nl> Timestamp TransactionParticipant : : prepareTransaction ( OperationContext * opCtx , <nl> } <nl> } ) ; <nl> <nl> - _txnState . transitionTo ( lk , TransactionState : : kPrepared ) ; <nl> - <nl> boost : : optional < OplogSlotReserver > oplogSlotReserver ; <nl> OplogSlot prepareOplogSlot ; <nl> + { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kPrepared ) ; <nl> + } <nl> + <nl> if ( prepareOptime ) { <nl> / / On secondary , we just prepare the transaction and discard the buffered ops . <nl> prepareOplogSlot = OplogSlot ( * prepareOptime , 0 ) ; <nl> - _prepareOpTime = * prepareOptime ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . prepareOpTime = * prepareOptime ; <nl> } else { <nl> / / On primary , we reserve an optime , prepare the transaction and write the oplog entry . <nl> / / <nl> Timestamp TransactionParticipant : : prepareTransaction ( OperationContext * opCtx , <nl> / / corresponding oplog hole ) will vanish . <nl> oplogSlotReserver . emplace ( opCtx ) ; <nl> prepareOplogSlot = oplogSlotReserver - > getReservedOplogSlot ( ) ; <nl> - invariant ( _prepareOpTime . isNull ( ) , <nl> + invariant ( o ( ) . prepareOpTime . isNull ( ) , <nl> str : : stream ( ) < < " This transaction has already reserved a prepareOpTime at : " <nl> - < < _prepareOpTime . toString ( ) ) ; <nl> - _prepareOpTime = prepareOplogSlot . opTime ; <nl> + < < o ( ) . prepareOpTime . toString ( ) ) ; <nl> + <nl> + { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . prepareOpTime = prepareOplogSlot . opTime ; <nl> + } <nl> <nl> if ( MONGO_FAIL_POINT ( hangAfterReservingPrepareTimestamp ) ) { <nl> / / This log output is used in js tests so please leave it . <nl> Timestamp TransactionParticipant : : prepareTransaction ( OperationContext * opCtx , <nl> opCtx - > recoveryUnit ( ) - > setPrepareTimestamp ( prepareOplogSlot . opTime . getTimestamp ( ) ) ; <nl> opCtx - > getWriteUnitOfWork ( ) - > prepare ( ) ; <nl> <nl> - / / We need to unlock the session to run the opObserver onTransactionPrepare , which calls back <nl> - / / into the session . <nl> - lk . unlock ( ) ; <nl> opCtx - > getServiceContext ( ) - > getOpObserver ( ) - > onTransactionPrepare ( <nl> opCtx , prepareOplogSlot , retrieveCompletedTransactionOperations ( opCtx ) ) ; <nl> <nl> abortGuard . dismiss ( ) ; <nl> <nl> - invariant ( ! _oldestOplogEntryOpTime , <nl> + / / For prepared transactions , we must update ServerTransactionMetrics with the prepare optime <nl> + / / before the prepare oplog entry is written so that we don ' t incorrectly advance the stable <nl> + / / timestamp . <nl> + invariant ( ! p ( ) . oldestOplogEntryOpTime , <nl> str : : stream ( ) < < " This transaction ' s oldest oplog entry Timestamp has already " <nl> < < " been set to : " <nl> - < < _oldestOplogEntryOpTime - > toString ( ) ) ; <nl> + < < p ( ) . oldestOplogEntryOpTime - > toString ( ) ) ; <nl> / / Keep track of the Timestamp from the first oplog entry written by this transaction . <nl> - _oldestOplogEntryOpTime = prepareOplogSlot . opTime ; <nl> + p ( ) . oldestOplogEntryOpTime = prepareOplogSlot . opTime ; <nl> <nl> / / Maintain the OpTime of the oldest active oplog entry for this transaction . We currently <nl> / / only write an oplog entry for an in progress transaction when it is in the prepare state <nl> / / but this will change when we allow multiple oplog entries per transaction . <nl> { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - const auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> - _transactionMetricsObserver . onPrepare ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> - * _oldestOplogEntryOpTime , <nl> - tickSource - > getTicks ( ) ) ; <nl> + const auto ticks = opCtx - > getServiceContext ( ) - > getTickSource ( ) - > getTicks ( ) ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onPrepare ( <nl> + ServerTransactionsMetrics : : get ( opCtx ) , * p ( ) . oldestOplogEntryOpTime , ticks ) ; <nl> } <nl> <nl> if ( MONGO_FAIL_POINT ( hangAfterSettingPrepareStartTime ) ) { <nl> Timestamp TransactionParticipant : : prepareTransaction ( OperationContext * opCtx , <nl> return prepareOplogSlot . opTime . getTimestamp ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : addTransactionOperation ( OperationContext * opCtx , <nl> - const repl : : ReplOperation & operation ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - <nl> - / / Always check _getSession ( ) ' s txnNumber and ' _txnState ' , since they can be modified by session <nl> - / / kill and migration , which do not check out the session . <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> + void TransactionParticipant : : Participant : : addTransactionOperation ( <nl> + OperationContext * opCtx , const repl : : ReplOperation & operation ) { <nl> <nl> / / Ensure that we only ever add operations to an in progress transaction . <nl> - invariant ( _txnState . isInProgress ( lk ) , str : : stream ( ) < < " Current state : " < < _txnState ) ; <nl> + invariant ( o ( ) . txnState . isInProgress ( ) , str : : stream ( ) < < " Current state : " < < o ( ) . txnState ) ; <nl> <nl> - invariant ( _autoCommit & & ! * _autoCommit & & _activeTxnNumber ! = kUninitializedTxnNumber ) ; <nl> + invariant ( p ( ) . autoCommit & & ! * p ( ) . autoCommit & & o ( ) . activeTxnNumber ! = kUninitializedTxnNumber ) ; <nl> invariant ( opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) ) ; <nl> - _transactionOperations . push_back ( operation ) ; <nl> - _transactionOperationBytes + = repl : : OplogEntry : : getReplOperationSize ( operation ) ; <nl> + p ( ) . transactionOperations . push_back ( operation ) ; <nl> + p ( ) . transactionOperationBytes + = repl : : OplogEntry : : getReplOperationSize ( operation ) ; <nl> / / _transactionOperationBytes is based on the in - memory size of the operation . With overhead , <nl> / / we expect the BSON size of the operation to be larger , so it ' s possible to make a transaction <nl> / / just a bit too large and have it fail only in the commit . It ' s still useful to fail early <nl> void TransactionParticipant : : addTransactionOperation ( OperationContext * opCtx , <nl> str : : stream ( ) < < " Total size of all transaction operations must be less than " <nl> < < BSONObjMaxInternalSize <nl> < < " . Actual size is " <nl> - < < _transactionOperationBytes , <nl> + < < p ( ) . transactionOperationBytes , <nl> useMultipleOplogEntryFormatForTransactions | | <nl> - _transactionOperationBytes < = BSONObjMaxInternalSize ) ; <nl> + p ( ) . transactionOperationBytes < = BSONObjMaxInternalSize ) ; <nl> } <nl> <nl> - std : : vector < repl : : ReplOperation > & TransactionParticipant : : retrieveCompletedTransactionOperations ( <nl> + std : : vector < repl : : ReplOperation > & <nl> + TransactionParticipant : : Participant : : retrieveCompletedTransactionOperations ( <nl> OperationContext * opCtx ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - <nl> - / / Always check session ' s txnNumber and ' _txnState ' , since they can be modified by session kill <nl> - / / and migration , which do not check out the session . <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> <nl> / / Ensure that we only ever retrieve a transaction ' s completed operations when in progress , <nl> / / committing with prepare , or prepared . <nl> - invariant ( _txnState . isInSet ( lk , <nl> - TransactionState : : kInProgress | <nl> - TransactionState : : kCommittingWithPrepare | <nl> - TransactionState : : kPrepared ) , <nl> - str : : stream ( ) < < " Current state : " < < _txnState ) ; <nl> + invariant ( o ( ) . txnState . isInSet ( TransactionState : : kInProgress | <nl> + TransactionState : : kCommittingWithPrepare | <nl> + TransactionState : : kPrepared ) , <nl> + str : : stream ( ) < < " Current state : " < < o ( ) . txnState ) ; <nl> <nl> - return _transactionOperations ; <nl> + return p ( ) . transactionOperations ; <nl> } <nl> <nl> - void TransactionParticipant : : clearOperationsInMemory ( OperationContext * opCtx ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - <nl> - / / Always check session ' s txnNumber and ' _txnState ' , since they can be modified by session kill <nl> - / / and migration , which do not check out the session . <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> - <nl> + void TransactionParticipant : : Participant : : clearOperationsInMemory ( OperationContext * opCtx ) { <nl> / / Ensure that we only ever end a transaction when committing with prepare or in progress . <nl> - invariant ( _txnState . isInSet ( <nl> - lk , TransactionState : : kCommittingWithPrepare | TransactionState : : kInProgress ) , <nl> - str : : stream ( ) < < " Current state : " < < _txnState ) ; <nl> - <nl> - invariant ( _autoCommit ) ; <nl> - _transactionOperationBytes = 0 ; <nl> - _transactionOperations . clear ( ) ; <nl> + invariant ( o ( ) . txnState . isInSet ( TransactionState : : kCommittingWithPrepare | <nl> + TransactionState : : kInProgress ) , <nl> + str : : stream ( ) < < " Current state : " < < o ( ) . txnState ) ; <nl> + invariant ( p ( ) . autoCommit ) ; <nl> + p ( ) . transactionOperationBytes = 0 ; <nl> + p ( ) . transactionOperations . clear ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : commitUnpreparedTransaction ( OperationContext * opCtx ) { <nl> - stdx : : unique_lock < stdx : : mutex > lk ( _mutex ) ; <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> - <nl> + void TransactionParticipant : : Participant : : commitUnpreparedTransaction ( OperationContext * opCtx ) { <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " commitTransaction must provide commitTimestamp to prepared transaction . " , <nl> - ! _txnState . isPrepared ( lk ) ) ; <nl> + ! o ( ) . txnState . isPrepared ( ) ) ; <nl> <nl> / / TODO SERVER - 37129 : Remove this invariant once we allow transactions larger than 16MB . <nl> - invariant ( ! _oldestOplogEntryOpTime , <nl> + invariant ( ! p ( ) . oldestOplogEntryOpTime , <nl> str : : stream ( ) < < " The oldest oplog entry Timestamp should not have been set because " <nl> < < " this transaction is not prepared . But , it is currently " <nl> - < < _oldestOplogEntryOpTime - > toString ( ) ) ; <nl> + < < p ( ) . oldestOplogEntryOpTime - > toString ( ) ) ; <nl> <nl> - / / We need to unlock the session to run the opObserver onTransactionCommit , which calls back <nl> - / / into the session . <nl> - lk . unlock ( ) ; <nl> auto opObserver = opCtx - > getServiceContext ( ) - > getOpObserver ( ) ; <nl> invariant ( opObserver ) ; <nl> opObserver - > onTransactionCommit ( <nl> opCtx , boost : : none , boost : : none , retrieveCompletedTransactionOperations ( opCtx ) ) ; <nl> - <nl> clearOperationsInMemory ( opCtx ) ; <nl> + { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + / / The oplog entry is written in the same WUOW with the data change for unprepared <nl> + / / transactions . We can still consider the state is InProgress until now , since no <nl> + / / externally visible changes have been made yet by the commit operation . If anything throws <nl> + / / before this point in the function , entry point will abort the transaction . <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kCommittingWithoutPrepare ) ; <nl> + } <nl> <nl> - lk . lock ( ) ; <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> - <nl> - / / The oplog entry is written in the same WUOW with the data change for unprepared transactions . <nl> - / / We can still consider the state is InProgress until now , since no externally visible changes <nl> - / / have been made yet by the commit operation . If anything throws before this point in the <nl> - / / function , entry point will abort the transaction . <nl> - _txnState . transitionTo ( lk , TransactionState : : kCommittingWithoutPrepare ) ; <nl> - <nl> - lk . unlock ( ) ; <nl> _commitStorageTransaction ( opCtx ) ; <nl> - lk . lock ( ) ; <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , false ) ; <nl> - invariant ( _txnState . isCommittingWithoutPrepare ( lk ) , <nl> - str : : stream ( ) < < " Current State : " < < _txnState ) ; <nl> - <nl> - _finishCommitTransaction ( lk , opCtx ) ; <nl> + invariant ( o ( ) . txnState . isCommittingWithoutPrepare ( ) , <nl> + str : : stream ( ) < < " Current State : " < < o ( ) . txnState ) ; <nl> + _finishCommitTransaction ( opCtx ) ; <nl> } <nl> <nl> - void TransactionParticipant : : commitPreparedTransaction ( <nl> + void TransactionParticipant : : Participant : : commitPreparedTransaction ( <nl> OperationContext * opCtx , <nl> Timestamp commitTimestamp , <nl> boost : : optional < repl : : OpTime > commitOplogEntryOpTime ) { <nl> void TransactionParticipant : : commitPreparedTransaction ( <nl> replCoord - > canAcceptWritesForDatabase ( opCtx , " admin " ) ) ; <nl> } <nl> <nl> - stdx : : unique_lock < stdx : : mutex > lk ( _mutex ) ; <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> - <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " commitTransaction cannot provide commitTimestamp to unprepared transaction . " , <nl> - _txnState . isPrepared ( lk ) ) ; <nl> + o ( ) . txnState . isPrepared ( ) ) ; <nl> uassert ( <nl> ErrorCodes : : InvalidOptions , " ' commitTimestamp ' cannot be null " , ! commitTimestamp . isNull ( ) ) ; <nl> uassert ( ErrorCodes : : InvalidOptions , <nl> " ' commitTimestamp ' must be greater than the ' prepareTimestamp ' " , <nl> - commitTimestamp > _prepareOpTime . getTimestamp ( ) ) ; <nl> + commitTimestamp > o ( ) . prepareOpTime . getTimestamp ( ) ) ; <nl> <nl> - _txnState . transitionTo ( lk , TransactionState : : kCommittingWithPrepare ) ; <nl> - opCtx - > recoveryUnit ( ) - > setCommitTimestamp ( commitTimestamp ) ; <nl> + { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kCommittingWithPrepare ) ; <nl> + } <nl> <nl> try { <nl> + opCtx - > recoveryUnit ( ) - > setCommitTimestamp ( commitTimestamp ) ; <nl> UninterruptibleLockGuard noInterrupt ( opCtx - > lockState ( ) ) ; <nl> <nl> / / On secondary , we generate a fake empty oplog slot , since it ' s not used by opObserver . <nl> void TransactionParticipant : : commitPreparedTransaction ( <nl> invariant ( commitOplogEntryOpTime ) ; <nl> } <nl> <nl> - / / We need to unlock the session to run the opObserver onTransactionCommit , which calls back <nl> - / / into the session . We also do not want to write to storage with the mutex locked . <nl> - lk . unlock ( ) ; <nl> _commitStorageTransaction ( opCtx ) ; <nl> <nl> auto opObserver = opCtx - > getServiceContext ( ) - > getOpObserver ( ) ; <nl> invariant ( opObserver ) ; <nl> <nl> - { <nl> - / / Once the transaction is committed , the oplog entry must be written . <nl> - UninterruptibleLockGuard lockGuard ( opCtx - > lockState ( ) ) ; <nl> - opObserver - > onTransactionCommit ( opCtx , <nl> - commitOplogSlot , <nl> - commitTimestamp , <nl> - retrieveCompletedTransactionOperations ( opCtx ) ) ; <nl> - } <nl> + / / Once the transaction is committed , the oplog entry must be written . <nl> + opObserver - > onTransactionCommit ( <nl> + opCtx , commitOplogSlot , commitTimestamp , retrieveCompletedTransactionOperations ( opCtx ) ) ; <nl> <nl> clearOperationsInMemory ( opCtx ) ; <nl> <nl> - lk . lock ( ) ; <nl> - _checkIsActiveTransaction ( lk , * opCtx - > getTxnNumber ( ) , true ) ; <nl> - <nl> / / If we are committing a prepared transaction , then we must have already recorded this <nl> / / transaction ' s oldest oplog entry optime . <nl> - invariant ( _oldestOplogEntryOpTime ) ; <nl> + invariant ( p ( ) . oldestOplogEntryOpTime ) ; <nl> / / If commitOplogEntryOpTime is a nullopt , then we grab the OpTime from the commitOplogSlot <nl> / / which will only be set if we are primary . Otherwise , the commitOplogEntryOpTime must have <nl> / / been passed in during secondary oplog application . <nl> - _finishOpTime = commitOplogEntryOpTime . value_or ( commitOplogSlot . opTime ) ; <nl> + p ( ) . finishOpTime = commitOplogEntryOpTime . value_or ( commitOplogSlot . opTime ) ; <nl> <nl> - _finishCommitTransaction ( lk , opCtx ) ; <nl> + _finishCommitTransaction ( opCtx ) ; <nl> } catch ( . . . ) { <nl> / / It is illegal for committing a prepared transaction to fail for any reason , other than an <nl> / / invalid command , so we crash instead . <nl> void TransactionParticipant : : commitPreparedTransaction ( <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : _commitStorageTransaction ( OperationContext * opCtx ) try { <nl> + void TransactionParticipant : : Participant : : _commitStorageTransaction ( OperationContext * opCtx ) try { <nl> invariant ( opCtx - > getWriteUnitOfWork ( ) ) ; <nl> invariant ( opCtx - > lockState ( ) - > isRSTLLocked ( ) ) ; <nl> opCtx - > getWriteUnitOfWork ( ) - > commit ( ) ; <nl> void TransactionParticipant : : _commitStorageTransaction ( OperationContext * opCtx ) <nl> std : : terminate ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _finishCommitTransaction ( WithLock lk , OperationContext * opCtx ) { <nl> + void TransactionParticipant : : Participant : : _finishCommitTransaction ( OperationContext * opCtx ) { <nl> / / If no writes have been done , set the client optime forward to the read timestamp so waiting <nl> / / for write concern will ensure all read data was committed . <nl> / / <nl> / / TODO ( SERVER - 34881 ) : Once the default read concern is speculative majority , only set the <nl> / / client optime forward if the original read concern level is " majority " or " snapshot " . <nl> auto & clientInfo = repl : : ReplClientInfo : : forClient ( opCtx - > getClient ( ) ) ; <nl> - if ( _speculativeTransactionReadOpTime > clientInfo . getLastOp ( ) ) { <nl> - clientInfo . setLastOp ( _speculativeTransactionReadOpTime ) ; <nl> + if ( p ( ) . speculativeTransactionReadOpTime > clientInfo . getLastOp ( ) ) { <nl> + clientInfo . setLastOp ( p ( ) . speculativeTransactionReadOpTime ) ; <nl> } <nl> - const bool isCommittingWithPrepare = _txnState . isCommittingWithPrepare ( lk ) ; <nl> - _txnState . transitionTo ( lk , TransactionState : : kCommitted ) ; <nl> <nl> { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> - _transactionMetricsObserver . onCommit ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> - tickSource , <nl> - _oldestOplogEntryOpTime , <nl> - _finishOpTime , <nl> - & Top : : get ( getGlobalServiceContext ( ) ) , <nl> - isCommittingWithPrepare ) ; <nl> - _transactionMetricsObserver . onTransactionOperation ( <nl> + const bool isCommittingWithPrepare = o ( ) . txnState . isCommittingWithPrepare ( ) ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kCommitted ) ; <nl> + <nl> + o ( lk ) . transactionMetricsObserver . onCommit ( ServerTransactionsMetrics : : get ( opCtx ) , <nl> + tickSource , <nl> + p ( ) . oldestOplogEntryOpTime , <nl> + p ( ) . finishOpTime , <nl> + & Top : : get ( getGlobalServiceContext ( ) ) , <nl> + isCommittingWithPrepare ) ; <nl> + o ( lk ) . transactionMetricsObserver . onTransactionOperation ( <nl> opCtx - > getClient ( ) , <nl> CurOp : : get ( opCtx ) - > debug ( ) . additiveMetrics , <nl> CurOp : : get ( opCtx ) - > debug ( ) . storageStats ) ; <nl> } <nl> - <nl> / / We must clear the recovery unit and locker so any post - transaction writes can run without <nl> / / transactional settings such as a read timestamp . <nl> - _cleanUpTxnResourceOnOpCtx ( lk , opCtx , TerminationCause : : kCommitted ) ; <nl> + _cleanUpTxnResourceOnOpCtx ( opCtx , TerminationCause : : kCommitted ) ; <nl> } <nl> <nl> - void TransactionParticipant : : shutdown ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lock ( _mutex ) ; <nl> + void TransactionParticipant : : Participant : : shutdown ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lock ( * opCtx - > getClient ( ) ) ; <nl> <nl> - _inShutdown = true ; <nl> - _txnResourceStash = boost : : none ; <nl> + p ( ) . inShutdown = true ; <nl> + o ( lock ) . txnResourceStash = boost : : none ; <nl> } <nl> <nl> - void TransactionParticipant : : abortArbitraryTransaction ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lock ( _mutex ) ; <nl> - <nl> - if ( ! _txnState . isInProgress ( lock ) ) { <nl> + void TransactionParticipant : : Participant : : abortTransactionIfNotPrepared ( OperationContext * opCtx ) { <nl> + if ( ! o ( ) . txnState . isInProgress ( ) ) { <nl> / / We do not want to abort transactions that are prepared unless we get an <nl> / / ' abortTransaction ' command . <nl> return ; <nl> } <nl> <nl> - _abortTransactionOnSession ( lock ) ; <nl> + _abortTransactionOnSession ( opCtx ) ; <nl> } <nl> <nl> - bool TransactionParticipant : : expired ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lock ( _mutex ) ; <nl> - <nl> - return _txnState . isInProgress ( lock ) & & _transactionExpireDate & & <nl> - _transactionExpireDate < getGlobalServiceContext ( ) - > getPreciseClockSource ( ) - > now ( ) ; <nl> + bool TransactionParticipant : : Observer : : expiredAsOf ( Date_t when ) const { <nl> + return o ( ) . txnState . isInProgress ( ) & & o ( ) . transactionExpireDate & & <nl> + o ( ) . transactionExpireDate < when ; <nl> } <nl> <nl> - void TransactionParticipant : : abortActiveTransaction ( OperationContext * opCtx ) { <nl> - stdx : : unique_lock < stdx : : mutex > lock ( _mutex ) ; <nl> - <nl> + void TransactionParticipant : : Participant : : abortActiveTransaction ( OperationContext * opCtx ) { <nl> / / Re - acquire the RSTL to prevent state transitions while aborting the transaction . If the <nl> / / transaction was prepared then we dropped it on preparing the transaction . We do not need to <nl> / / reacquire the PBWM because if we ' re not the primary we will uassert anyways . <nl> Lock : : ResourceLock rstl ( opCtx - > lockState ( ) , resourceIdReplicationStateTransitionLock , MODE_IX ) ; <nl> - if ( _txnState . isPrepared ( lock ) & & opCtx - > writesAreReplicated ( ) ) { <nl> + if ( o ( ) . txnState . isPrepared ( ) & & opCtx - > writesAreReplicated ( ) ) { <nl> auto replCoord = repl : : ReplicationCoordinator : : get ( opCtx ) ; <nl> uassert ( ErrorCodes : : NotMaster , <nl> " Not primary so we cannot abort a prepared transaction " , <nl> replCoord - > canAcceptWritesForDatabase ( opCtx , " admin " ) ) ; <nl> } <nl> <nl> - / / This function shouldn ' t throw if the transaction is already aborted . <nl> - _checkIsActiveTransaction ( lock , * opCtx - > getTxnNumber ( ) , false ) ; <nl> - _abortActiveTransaction ( <nl> - std : : move ( lock ) , opCtx , TransactionState : : kInProgress | TransactionState : : kPrepared ) ; <nl> + _abortActiveTransaction ( opCtx , TransactionState : : kInProgress | TransactionState : : kPrepared ) ; <nl> } <nl> <nl> - void TransactionParticipant : : abortActiveUnpreparedOrStashPreparedTransaction ( <nl> + void TransactionParticipant : : Participant : : abortActiveUnpreparedOrStashPreparedTransaction ( <nl> OperationContext * opCtx ) try { <nl> - stdx : : unique_lock < stdx : : mutex > lock ( _mutex ) ; <nl> - if ( _txnState . isInSet ( lock , TransactionState : : kNone | TransactionState : : kCommitted ) ) { <nl> + if ( o ( ) . txnState . isInSet ( TransactionState : : kNone | TransactionState : : kCommitted ) ) { <nl> / / If there is no active transaction , do nothing . <nl> return ; <nl> } <nl> <nl> - / / We do this check to follow convention and maintain safety . If this were to throw we should <nl> - / / have returned in the check above . As a result , throwing here is fatal . <nl> - _checkIsActiveTransaction ( lock , * opCtx - > getTxnNumber ( ) , false ) ; <nl> - <nl> / / Stash the transaction if it ' s in prepared state . <nl> - if ( _txnState . isInSet ( lock , TransactionState : : kPrepared ) ) { <nl> - _stashActiveTransaction ( lock , opCtx ) ; <nl> + if ( o ( ) . txnState . isInSet ( TransactionState : : kPrepared ) ) { <nl> + _stashActiveTransaction ( opCtx ) ; <nl> return ; <nl> } <nl> <nl> / / TODO SERVER - 37129 : Remove this invariant once we allow transactions larger than 16MB . <nl> - invariant ( ! _oldestOplogEntryOpTime , <nl> + invariant ( ! p ( ) . oldestOplogEntryOpTime , <nl> str : : stream ( ) < < " The oldest oplog entry Timestamp should not have been set because " <nl> < < " this transaction is not prepared . But , it is currently " <nl> - < < _oldestOplogEntryOpTime - > toString ( ) ) ; <nl> + < < p ( ) . oldestOplogEntryOpTime - > toString ( ) ) ; <nl> <nl> - _abortActiveTransaction ( std : : move ( lock ) , opCtx , TransactionState : : kInProgress ) ; <nl> + _abortActiveTransaction ( opCtx , TransactionState : : kInProgress ) ; <nl> } catch ( . . . ) { <nl> / / It is illegal for this to throw so we catch and log this here for diagnosability . <nl> severe ( ) < < " Caught exception during transaction " < < opCtx - > getTxnNumber ( ) <nl> - < < " abort or stash on " < < _sessionId ( ) . toBSON ( ) < < " in state " < < _txnState < < " : " <nl> - < < exceptionToStatus ( ) ; <nl> + < < " abort or stash on " < < _sessionId ( ) . toBSON ( ) < < " in state " < < o ( ) . txnState <nl> + < < " : " < < exceptionToStatus ( ) ; <nl> std : : terminate ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _abortActiveTransaction ( stdx : : unique_lock < stdx : : mutex > lock , <nl> - OperationContext * opCtx , <nl> - TransactionState : : StateSet expectedStates ) { <nl> - invariant ( ! _txnResourceStash ) ; <nl> - invariant ( ! _txnState . isCommittingWithPrepare ( lock ) ) ; <nl> + void TransactionParticipant : : Participant : : _abortActiveTransaction ( <nl> + OperationContext * opCtx , TransactionState : : StateSet expectedStates ) { <nl> + invariant ( ! o ( ) . txnResourceStash ) ; <nl> + invariant ( ! o ( ) . txnState . isCommittingWithPrepare ( ) ) ; <nl> <nl> - if ( ! _txnState . isNone ( lock ) ) { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onTransactionOperation ( <nl> + if ( ! o ( ) . txnState . isNone ( ) ) { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onTransactionOperation ( <nl> opCtx - > getClient ( ) , <nl> CurOp : : get ( opCtx ) - > debug ( ) . additiveMetrics , <nl> CurOp : : get ( opCtx ) - > debug ( ) . storageStats ) ; <nl> void TransactionParticipant : : _abortActiveTransaction ( stdx : : unique_lock < stdx : : mut <nl> / / OpObserver . <nl> boost : : optional < OplogSlotReserver > oplogSlotReserver ; <nl> boost : : optional < OplogSlot > abortOplogSlot ; <nl> - if ( _txnState . isPrepared ( lock ) & & opCtx - > writesAreReplicated ( ) ) { <nl> + if ( o ( ) . txnState . isPrepared ( ) & & opCtx - > writesAreReplicated ( ) ) { <nl> oplogSlotReserver . emplace ( opCtx ) ; <nl> abortOplogSlot = oplogSlotReserver - > getReservedOplogSlot ( ) ; <nl> } <nl> <nl> / / Clean up the transaction resources on the opCtx even if the transaction resources on the <nl> / / session were not aborted . This actually aborts the storage - transaction . <nl> - _cleanUpTxnResourceOnOpCtx ( lock , opCtx , TerminationCause : : kAborted ) ; <nl> + _cleanUpTxnResourceOnOpCtx ( opCtx , TerminationCause : : kAborted ) ; <nl> <nl> / / Write the abort oplog entry . This must be done after aborting the storage transaction , so <nl> - / / that the lock state is reset , and there is no max lock timeout on the locker . We need to <nl> - / / unlock the session to run the opObserver onTransactionAbort , which calls back into the <nl> - / / session . <nl> - lock . unlock ( ) ; <nl> - <nl> + / / that the lock state is reset , and there is no max lock timeout on the locker . <nl> auto opObserver = opCtx - > getServiceContext ( ) - > getOpObserver ( ) ; <nl> invariant ( opObserver ) ; <nl> opObserver - > onTransactionAbort ( opCtx , abortOplogSlot ) ; <nl> <nl> - lock . lock ( ) ; <nl> - / / We do not check if the active transaction number is correct here because we handle it below . <nl> - <nl> / / Set the finishOpTime of this transaction if we have recorded this transaction ' s oldest oplog <nl> / / entry optime . <nl> - if ( _oldestOplogEntryOpTime ) { <nl> - _finishOpTime = repl : : ReplClientInfo : : forClient ( opCtx - > getClient ( ) ) . getLastOp ( ) ; <nl> + if ( p ( ) . oldestOplogEntryOpTime ) { <nl> + p ( ) . finishOpTime = repl : : ReplClientInfo : : forClient ( opCtx - > getClient ( ) ) . getLastOp ( ) ; <nl> } <nl> <nl> / / Only abort the transaction in session if it ' s in expected states . <nl> / / When the state of active transaction on session is not expected , it means another <nl> / / thread has already aborted the transaction on session . <nl> - if ( _txnState . isInSet ( lock , expectedStates ) ) { <nl> - invariant ( opCtx - > getTxnNumber ( ) = = _activeTxnNumber ) ; <nl> - _abortTransactionOnSession ( lock ) ; <nl> - } else if ( opCtx - > getTxnNumber ( ) = = _activeTxnNumber ) { <nl> - if ( _txnState . isNone ( lock ) ) { <nl> + if ( o ( ) . txnState . isInSet ( expectedStates ) ) { <nl> + invariant ( opCtx - > getTxnNumber ( ) = = o ( ) . activeTxnNumber ) ; <nl> + _abortTransactionOnSession ( opCtx ) ; <nl> + } else if ( opCtx - > getTxnNumber ( ) = = o ( ) . activeTxnNumber ) { <nl> + if ( o ( ) . txnState . isNone ( ) ) { <nl> / / The active transaction is not a multi - document transaction . <nl> invariant ( opCtx - > getWriteUnitOfWork ( ) = = nullptr ) ; <nl> return ; <nl> void TransactionParticipant : : _abortActiveTransaction ( stdx : : unique_lock < stdx : : mut <nl> | TransactionState : : kCommittingWithPrepare / / <nl> | TransactionState : : kCommittingWithoutPrepare / / <nl> | TransactionState : : kCommitted ; / / <nl> - invariant ( ! _txnState . isInSet ( lock , unabortableStates ) , <nl> - str : : stream ( ) < < " Cannot abort transaction in " < < _txnState . toString ( ) ) ; <nl> + invariant ( ! o ( ) . txnState . isInSet ( unabortableStates ) , <nl> + str : : stream ( ) < < " Cannot abort transaction in " < < o ( ) . txnState . toString ( ) ) ; <nl> } else { <nl> / / If _activeTxnNumber is higher than ours , it means the transaction is already aborted . <nl> - invariant ( _txnState . isInSet ( lock , <nl> - TransactionState : : kNone | <nl> - TransactionState : : kAbortedWithoutPrepare | <nl> - TransactionState : : kAbortedWithPrepare ) ) ; <nl> + invariant ( o ( ) . txnState . isInSet ( TransactionState : : kNone | <nl> + TransactionState : : kAbortedWithoutPrepare | <nl> + TransactionState : : kAbortedWithPrepare ) , <nl> + str : : stream ( ) < < " actual state : " < < o ( ) . txnState . toString ( ) ) ; <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : _abortTransactionOnSession ( WithLock wl ) { <nl> - const auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> + void TransactionParticipant : : Participant : : _abortTransactionOnSession ( OperationContext * opCtx ) { <nl> + const auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> / / If the transaction is stashed , then we have aborted an inactive transaction . <nl> - if ( _txnResourceStash ) { <nl> - / / The transaction is stashed , so we abort the inactive transaction on session . <nl> + if ( o ( ) . txnResourceStash ) { <nl> { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onAbortInactive ( <nl> - ServerTransactionsMetrics : : get ( getGlobalServiceContext ( ) ) , <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + / / The transaction is stashed , so we abort the inactive transaction on session . <nl> + o ( lk ) . transactionMetricsObserver . onAbortInactive ( <nl> + ServerTransactionsMetrics : : get ( opCtx - > getServiceContext ( ) ) , <nl> tickSource , <nl> - _oldestOplogEntryOpTime , <nl> - & Top : : get ( getGlobalServiceContext ( ) ) ) ; <nl> + p ( ) . oldestOplogEntryOpTime , <nl> + & Top : : get ( opCtx - > getServiceContext ( ) ) ) ; <nl> } <nl> - _logSlowTransaction ( wl , <nl> - & ( _txnResourceStash - > locker ( ) - > getLockerInfo ( boost : : none ) ) - > stats , <nl> + _logSlowTransaction ( opCtx , <nl> + & ( o ( ) . txnResourceStash - > locker ( ) - > getLockerInfo ( boost : : none ) ) - > stats , <nl> TerminationCause : : kAborted , <nl> - _txnResourceStash - > getReadConcernArgs ( ) ) ; <nl> + o ( ) . txnResourceStash - > getReadConcernArgs ( ) ) ; <nl> } else { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . onAbortActive ( <nl> - ServerTransactionsMetrics : : get ( getGlobalServiceContext ( ) ) , <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . transactionMetricsObserver . onAbortActive ( <nl> + ServerTransactionsMetrics : : get ( opCtx - > getServiceContext ( ) ) , <nl> tickSource , <nl> - _oldestOplogEntryOpTime , <nl> - _finishOpTime , <nl> - & Top : : get ( getGlobalServiceContext ( ) ) , <nl> - _txnState . isPrepared ( lm ) ) ; <nl> + p ( ) . oldestOplogEntryOpTime , <nl> + p ( ) . finishOpTime , <nl> + & Top : : get ( opCtx - > getServiceContext ( ) ) , <nl> + o ( ) . txnState . isPrepared ( ) ) ; <nl> } <nl> <nl> - const auto nextState = _txnState . isPrepared ( wl ) ? TransactionState : : kAbortedWithPrepare <nl> - : TransactionState : : kAbortedWithoutPrepare ; <nl> - _resetTransactionState ( wl , nextState ) ; <nl> + const auto nextState = o ( ) . txnState . isPrepared ( ) ? TransactionState : : kAbortedWithPrepare <nl> + : TransactionState : : kAbortedWithoutPrepare ; <nl> + <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + _resetTransactionState ( lk , nextState ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _cleanUpTxnResourceOnOpCtx ( WithLock wl , <nl> - OperationContext * opCtx , <nl> - TerminationCause terminationCause ) { <nl> + void TransactionParticipant : : Participant : : _cleanUpTxnResourceOnOpCtx ( <nl> + OperationContext * opCtx , TerminationCause terminationCause ) { <nl> / / Log the transaction if its duration is longer than the slowMS command threshold . <nl> _logSlowTransaction ( <nl> - wl , <nl> + opCtx , <nl> & ( opCtx - > lockState ( ) - > getLockerInfo ( CurOp : : get ( * opCtx ) - > getLockStatsBase ( ) ) ) - > stats , <nl> terminationCause , <nl> repl : : ReadConcernArgs : : get ( opCtx ) ) ; <nl> void TransactionParticipant : : _cleanUpTxnResourceOnOpCtx ( WithLock wl , <nl> opCtx - > lockState ( ) - > unsetMaxLockTimeout ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _checkIsActiveTransaction ( WithLock wl , <nl> - const TxnNumber & requestTxnNumber , <nl> - bool checkAbort ) const { <nl> - uassert ( ErrorCodes : : ConflictingOperationInProgress , <nl> - str : : stream ( ) < < " Cannot perform operations on requested transaction " <nl> - < < requestTxnNumber <nl> - < < " on session " <nl> - < < _sessionId ( ) <nl> - < < " because a different transaction " <nl> - < < _activeTxnNumber <nl> - < < " is now active . " , <nl> - requestTxnNumber = = _activeTxnNumber ) ; <nl> - <nl> - uassert ( ErrorCodes : : NoSuchTransaction , <nl> - str : : stream ( ) < < " Transaction " < < _activeTxnNumber < < " has been aborted . " , <nl> - ! checkAbort | | ! _txnState . isAborted ( wl ) ) ; <nl> - } <nl> - <nl> - void TransactionParticipant : : _checkIsCommandValidWithTxnState ( WithLock wl , <nl> - const TxnNumber & requestTxnNumber , <nl> - const std : : string & cmdName ) { <nl> - / / Throw NoSuchTransaction error instead of TransactionAborted error since this is the entry <nl> - / / point of transaction execution . <nl> + void TransactionParticipant : : Participant : : _checkIsCommandValidWithTxnState ( <nl> + const TxnNumber & requestTxnNumber , const std : : string & cmdName ) const { <nl> uassert ( ErrorCodes : : NoSuchTransaction , <nl> str : : stream ( ) < < " Transaction " < < requestTxnNumber < < " has been aborted . " , <nl> - ! _txnState . isAborted ( wl ) ) ; <nl> + ! o ( ) . txnState . isAborted ( ) ) ; <nl> <nl> / / Cannot change committed transaction but allow retrying commitTransaction command . <nl> uassert ( ErrorCodes : : TransactionCommitted , <nl> str : : stream ( ) < < " Transaction " < < requestTxnNumber < < " has been committed . " , <nl> - cmdName = = " commitTransaction " | | ! _txnState . isCommitted ( wl ) ) ; <nl> + cmdName = = " commitTransaction " | | ! o ( ) . txnState . isCommitted ( ) ) ; <nl> <nl> / / Disallow operations other than abort , prepare or commit on a prepared transaction <nl> uassert ( ErrorCodes : : PreparedTransactionInProgress , <nl> str : : stream ( ) < < " Cannot call any operation other than abort , prepare or commit on " <nl> < < " a prepared transaction " , <nl> - ! _txnState . isPrepared ( wl ) | | <nl> + ! o ( ) . txnState . isPrepared ( ) | | <nl> preparedTxnCmdWhitelist . find ( cmdName ) ! = preparedTxnCmdWhitelist . cend ( ) ) ; <nl> } <nl> <nl> - BSONObj TransactionParticipant : : reportStashedState ( ) const { <nl> + BSONObj TransactionParticipant : : Observer : : reportStashedState ( OperationContext * opCtx ) const { <nl> BSONObjBuilder builder ; <nl> - reportStashedState ( & builder ) ; <nl> + reportStashedState ( opCtx , & builder ) ; <nl> return builder . obj ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : reportStashedState ( BSONObjBuilder * builder ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _mutex ) ; <nl> - <nl> - if ( _txnResourceStash & & _txnResourceStash - > locker ( ) ) { <nl> - if ( auto lockerInfo = _txnResourceStash - > locker ( ) - > getLockerInfo ( boost : : none ) ) { <nl> - invariant ( _activeTxnNumber ! = kUninitializedTxnNumber ) ; <nl> + void TransactionParticipant : : Observer : : reportStashedState ( OperationContext * opCtx , <nl> + BSONObjBuilder * builder ) const { <nl> + if ( o ( ) . txnResourceStash & & o ( ) . txnResourceStash - > locker ( ) ) { <nl> + if ( auto lockerInfo = o ( ) . txnResourceStash - > locker ( ) - > getLockerInfo ( boost : : none ) ) { <nl> + invariant ( o ( ) . activeTxnNumber ! = kUninitializedTxnNumber ) ; <nl> builder - > append ( " type " , " idleSession " ) ; <nl> builder - > append ( " host " , getHostNameCachedAndPort ( ) ) ; <nl> builder - > append ( " desc " , " inactive transaction " ) ; <nl> <nl> const auto & lastClientInfo = <nl> - _transactionMetricsObserver . getSingleTransactionStats ( ) . getLastClientInfo ( ) ; <nl> + o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) . getLastClientInfo ( ) ; <nl> builder - > append ( " client " , lastClientInfo . clientHostAndPort ) ; <nl> builder - > append ( " connectionId " , lastClientInfo . connectionId ) ; <nl> builder - > append ( " appName " , lastClientInfo . appName ) ; <nl> void TransactionParticipant : : reportStashedState ( BSONObjBuilder * builder ) const { <nl> <nl> BSONObjBuilder transactionBuilder ; <nl> _reportTransactionStats ( <nl> - lm , & transactionBuilder , _txnResourceStash - > getReadConcernArgs ( ) ) ; <nl> + opCtx , & transactionBuilder , o ( ) . txnResourceStash - > getReadConcernArgs ( ) ) ; <nl> <nl> builder - > append ( " transaction " , transactionBuilder . obj ( ) ) ; <nl> builder - > append ( " waitingForLock " , false ) ; <nl> void TransactionParticipant : : reportStashedState ( BSONObjBuilder * builder ) const { <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : reportUnstashedState ( OperationContext * opCtx , <nl> - BSONObjBuilder * builder ) const { <nl> + void TransactionParticipant : : Observer : : reportUnstashedState ( OperationContext * opCtx , <nl> + BSONObjBuilder * builder ) const { <nl> / / This method may only take the metrics mutex , as it is called with the Client mutex held . So <nl> / / we cannot check the stashed state directly . Instead , a transaction is considered unstashed <nl> / / if it is not actually a transaction ( retryable write , no stash used ) , or is active ( not <nl> / / stashed ) , or has ended ( any stash would be cleared ) . <nl> <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - const auto & singleTransactionStats = _transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> + const auto & singleTransactionStats = o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> if ( ! singleTransactionStats . isForMultiDocumentTransaction ( ) | | <nl> singleTransactionStats . isActive ( ) | | singleTransactionStats . isEnded ( ) ) { <nl> BSONObjBuilder transactionBuilder ; <nl> - _reportTransactionStats ( lm , & transactionBuilder , repl : : ReadConcernArgs : : get ( opCtx ) ) ; <nl> + _reportTransactionStats ( opCtx , & transactionBuilder , repl : : ReadConcernArgs : : get ( opCtx ) ) ; <nl> builder - > append ( " transaction " , transactionBuilder . obj ( ) ) ; <nl> } <nl> } <nl> bool TransactionParticipant : : TransactionState : : _isLegalTransition ( StateFlag oldS <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl> - void TransactionParticipant : : TransactionState : : transitionTo ( WithLock , <nl> - StateFlag newState , <nl> + void TransactionParticipant : : TransactionState : : transitionTo ( StateFlag newState , <nl> TransitionValidation shouldValidate ) { <nl> if ( shouldValidate = = TransitionValidation : : kValidateTransition ) { <nl> invariant ( TransactionState : : _isLegalTransition ( _state , newState ) , <nl> void TransactionParticipant : : TransactionState : : transitionTo ( WithLock , <nl> _state = newState ; <nl> } <nl> <nl> - void TransactionParticipant : : _reportTransactionStats ( WithLock wl , <nl> - BSONObjBuilder * builder , <nl> - repl : : ReadConcernArgs readConcernArgs ) const { <nl> - const auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> - _transactionMetricsObserver . getSingleTransactionStats ( ) . report ( <nl> + void TransactionParticipant : : Observer : : _reportTransactionStats ( <nl> + OperationContext * opCtx , BSONObjBuilder * builder , repl : : ReadConcernArgs readConcernArgs ) const { <nl> + const auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> + o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) . report ( <nl> builder , readConcernArgs , tickSource , tickSource - > getTicks ( ) ) ; <nl> } <nl> <nl> - std : : string TransactionParticipant : : _transactionInfoForLog ( <nl> + std : : string TransactionParticipant : : Participant : : _transactionInfoForLog ( <nl> + OperationContext * opCtx , <nl> const SingleThreadedLockStats * lockStats , <nl> TerminationCause terminationCause , <nl> repl : : ReadConcernArgs readConcernArgs ) const { <nl> std : : string TransactionParticipant : : _transactionInfoForLog ( <nl> _sessionId ( ) . serialize ( & lsidBuilder ) ; <nl> lsidBuilder . doneFast ( ) ; <nl> <nl> - parametersBuilder . append ( " txnNumber " , _activeTxnNumber ) ; <nl> - parametersBuilder . append ( " autocommit " , _autoCommit ? * _autoCommit : true ) ; <nl> + parametersBuilder . append ( " txnNumber " , o ( ) . activeTxnNumber ) ; <nl> + parametersBuilder . append ( " autocommit " , p ( ) . autoCommit ? * p ( ) . autoCommit : true ) ; <nl> readConcernArgs . appendInfo ( & parametersBuilder ) ; <nl> <nl> s < < " parameters : " < < parametersBuilder . obj ( ) . toString ( ) < < " , " ; <nl> <nl> - s < < " readTimestamp : " < < _speculativeTransactionReadOpTime . getTimestamp ( ) . toString ( ) < < " , " ; <nl> + s < < " readTimestamp : " < < p ( ) . speculativeTransactionReadOpTime . getTimestamp ( ) . toString ( ) < < " , " ; <nl> <nl> - const auto & singleTransactionStats = _transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> + const auto & singleTransactionStats = o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> <nl> s < < singleTransactionStats . getOpDebug ( ) - > additiveMetrics . report ( ) ; <nl> <nl> std : : string TransactionParticipant : : _transactionInfoForLog ( <nl> terminationCause = = TerminationCause : : kCommitted ? " committed " : " aborted " ; <nl> s < < " terminationCause : " < < terminationCauseString ; <nl> <nl> - auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> + auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> auto curTick = tickSource - > getTicks ( ) ; <nl> <nl> s < < " timeActiveMicros : " <nl> std : : string TransactionParticipant : : _transactionInfoForLog ( <nl> s < < " wasPrepared : " < < txnWasPrepared ; <nl> if ( txnWasPrepared ) { <nl> s < < " totalPreparedDurationMicros : " < < totalPreparedDuration ; <nl> - s < < " prepareOpTime : " < < _prepareOpTime . toString ( ) ; <nl> + s < < " prepareOpTime : " < < o ( ) . prepareOpTime . toString ( ) ; <nl> } <nl> <nl> - if ( _oldestOplogEntryOpTime ) { <nl> - s < < " oldestOplogEntryOpTime : " < < _oldestOplogEntryOpTime - > toString ( ) ; <nl> + if ( p ( ) . oldestOplogEntryOpTime ) { <nl> + s < < " oldestOplogEntryOpTime : " < < p ( ) . oldestOplogEntryOpTime - > toString ( ) ; <nl> } <nl> <nl> - if ( _finishOpTime ) { <nl> - s < < " finishOpTime : " < < _finishOpTime - > toString ( ) ; <nl> + if ( p ( ) . finishOpTime ) { <nl> + s < < " finishOpTime : " < < p ( ) . finishOpTime - > toString ( ) ; <nl> } <nl> <nl> / / Total duration of the transaction . <nl> std : : string TransactionParticipant : : _transactionInfoForLog ( <nl> return s . str ( ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _logSlowTransaction ( WithLock wl , <nl> - const SingleThreadedLockStats * lockStats , <nl> - TerminationCause terminationCause , <nl> - repl : : ReadConcernArgs readConcernArgs ) { <nl> + void TransactionParticipant : : Participant : : _logSlowTransaction ( <nl> + OperationContext * opCtx , <nl> + const SingleThreadedLockStats * lockStats , <nl> + TerminationCause terminationCause , <nl> + repl : : ReadConcernArgs readConcernArgs ) { <nl> / / Only log multi - document transactions . <nl> - if ( ! _txnState . isNone ( wl ) ) { <nl> - const auto tickSource = getGlobalServiceContext ( ) - > getTickSource ( ) ; <nl> + if ( ! o ( ) . txnState . isNone ( ) ) { <nl> + const auto tickSource = opCtx - > getServiceContext ( ) - > getTickSource ( ) ; <nl> / / Log the transaction if its duration is longer than the slowMS command threshold . <nl> - if ( _transactionMetricsObserver . getSingleTransactionStats ( ) . getDuration ( <nl> + if ( o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) . getDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) > Milliseconds ( serverGlobalParams . slowMS ) ) { <nl> log ( logger : : LogComponent : : kTransaction ) <nl> < < " transaction " <nl> - < < _transactionInfoForLog ( lockStats , terminationCause , readConcernArgs ) ; <nl> + < < _transactionInfoForLog ( opCtx , lockStats , terminationCause , readConcernArgs ) ; <nl> } <nl> } <nl> } <nl> <nl> - void TransactionParticipant : : _setNewTxnNumber ( WithLock wl , const TxnNumber & txnNumber ) { <nl> + void TransactionParticipant : : Participant : : _setNewTxnNumber ( OperationContext * opCtx , <nl> + const TxnNumber & txnNumber ) { <nl> uassert ( ErrorCodes : : PreparedTransactionInProgress , <nl> " Cannot change transaction number while the session has a prepared transaction " , <nl> - ! _txnState . isInSet ( <nl> - wl , TransactionState : : kPrepared | TransactionState : : kCommittingWithPrepare ) ) ; <nl> + ! o ( ) . txnState . isInSet ( TransactionState : : kPrepared | <nl> + TransactionState : : kCommittingWithPrepare ) ) ; <nl> <nl> LOG_FOR_TRANSACTION ( 4 ) < < " New transaction started with txnNumber : " < < txnNumber <nl> < < " on session with lsid " < < _sessionId ( ) . getId ( ) ; <nl> <nl> / / Abort the existing transaction if it ' s not prepared , committed , or aborted . <nl> - if ( _txnState . isInProgress ( wl ) ) { <nl> - _abortTransactionOnSession ( wl ) ; <nl> + if ( o ( ) . txnState . isInProgress ( ) ) { <nl> + _abortTransactionOnSession ( opCtx ) ; <nl> } <nl> <nl> - _activeTxnNumber = txnNumber ; <nl> - _lastWriteOpTime = repl : : OpTime ( ) ; <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . activeTxnNumber = txnNumber ; <nl> + o ( lk ) . lastWriteOpTime = repl : : OpTime ( ) ; <nl> <nl> / / Reset the retryable writes state <nl> - _resetRetryableWriteState ( wl ) ; <nl> + _resetRetryableWriteState ( ) ; <nl> <nl> / / Reset the transactional state <nl> - _resetTransactionState ( wl , TransactionState : : kNone ) ; <nl> + _resetTransactionState ( lk , TransactionState : : kNone ) ; <nl> <nl> / / Reset the transactions metrics <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . resetSingleTransactionStats ( txnNumber ) ; <nl> + o ( lk ) . transactionMetricsObserver . resetSingleTransactionStats ( txnNumber ) ; <nl> } <nl> <nl> - void TransactionParticipant : : refreshFromStorageIfNeeded ( ) { <nl> - const auto opCtx = _opCtx ( ) ; <nl> + void TransactionParticipant : : Participant : : refreshFromStorageIfNeeded ( OperationContext * opCtx ) { <nl> invariant ( ! opCtx - > getClient ( ) - > isInDirectClient ( ) ) ; <nl> invariant ( ! opCtx - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> - if ( _isValid ) <nl> + if ( p ( ) . isValid ) <nl> return ; <nl> <nl> auto activeTxnHistory = fetchActiveTransactionHistory ( opCtx , _sessionId ( ) ) ; <nl> - <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - <nl> const auto & lastTxnRecord = activeTxnHistory . lastTxnRecord ; <nl> - <nl> if ( lastTxnRecord ) { <nl> - _activeTxnNumber = lastTxnRecord - > getTxnNum ( ) ; <nl> - _lastWriteOpTime = lastTxnRecord - > getLastWriteOpTime ( ) ; <nl> - _activeTxnCommittedStatements = std : : move ( activeTxnHistory . committedStatements ) ; <nl> - _hasIncompleteHistory = activeTxnHistory . hasIncompleteHistory ; <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> + o ( lg ) . activeTxnNumber = lastTxnRecord - > getTxnNum ( ) ; <nl> + o ( lg ) . lastWriteOpTime = lastTxnRecord - > getLastWriteOpTime ( ) ; <nl> + p ( ) . activeTxnCommittedStatements = std : : move ( activeTxnHistory . committedStatements ) ; <nl> + p ( ) . hasIncompleteHistory = activeTxnHistory . hasIncompleteHistory ; <nl> <nl> if ( activeTxnHistory . transactionCommitted ) { <nl> - _txnState . transitionTo ( <nl> - lg , <nl> + o ( lg ) . txnState . transitionTo ( <nl> TransactionState : : kCommitted , <nl> TransactionState : : TransitionValidation : : kRelaxTransitionValidation ) ; <nl> } <nl> } <nl> <nl> - _isValid = true ; <nl> + p ( ) . isValid = true ; <nl> } <nl> <nl> - void TransactionParticipant : : onWriteOpCompletedOnPrimary ( <nl> + void TransactionParticipant : : Participant : : onWriteOpCompletedOnPrimary ( <nl> OperationContext * opCtx , <nl> TxnNumber txnNumber , <nl> std : : vector < StmtId > stmtIdsWritten , <nl> void TransactionParticipant : : onWriteOpCompletedOnPrimary ( <nl> Date_t lastStmtIdWriteDate , <nl> boost : : optional < DurableTxnStateEnum > txnState ) { <nl> invariant ( opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) ) ; <nl> - invariant ( txnNumber = = _activeTxnNumber ) ; <nl> - <nl> - stdx : : unique_lock < stdx : : mutex > ul ( _mutex ) ; <nl> + invariant ( txnNumber = = o ( ) . activeTxnNumber ) ; <nl> <nl> / / Sanity check that we don ' t double - execute statements <nl> for ( const auto stmtId : stmtIdsWritten ) { <nl> void TransactionParticipant : : onWriteOpCompletedOnPrimary ( <nl> const auto updateRequest = <nl> _makeUpdateRequest ( lastStmtIdWriteOpTime , lastStmtIdWriteDate , txnState ) ; <nl> <nl> - ul . unlock ( ) ; <nl> - <nl> repl : : UnreplicatedWritesBlock doNotReplicateWrites ( opCtx ) ; <nl> <nl> updateSessionEntry ( opCtx , updateRequest ) ; <nl> - _registerUpdateCacheOnCommit ( std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ) ; <nl> + _registerUpdateCacheOnCommit ( opCtx , std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ) ; <nl> } <nl> <nl> - void TransactionParticipant : : onMigrateCompletedOnPrimary ( OperationContext * opCtx , <nl> - TxnNumber txnNumber , <nl> - std : : vector < StmtId > stmtIdsWritten , <nl> - const repl : : OpTime & lastStmtIdWriteOpTime , <nl> - Date_t oplogLastStmtIdWriteDate ) { <nl> + void TransactionParticipant : : Participant : : onMigrateCompletedOnPrimary ( <nl> + OperationContext * opCtx , <nl> + TxnNumber txnNumber , <nl> + std : : vector < StmtId > stmtIdsWritten , <nl> + const repl : : OpTime & lastStmtIdWriteOpTime , <nl> + Date_t oplogLastStmtIdWriteDate ) { <nl> invariant ( opCtx - > lockState ( ) - > inAWriteUnitOfWork ( ) ) ; <nl> - invariant ( txnNumber = = _activeTxnNumber ) ; <nl> - <nl> - stdx : : unique_lock < stdx : : mutex > ul ( _mutex ) ; <nl> - <nl> - _checkValid ( ul ) ; <nl> - _checkIsActiveTransaction ( ul , txnNumber ) ; <nl> + invariant ( txnNumber = = o ( ) . activeTxnNumber ) ; <nl> <nl> / / We do not migrate transaction oplog entries so don ' t set the txn state <nl> const auto txnState = boost : : none ; <nl> const auto updateRequest = <nl> _makeUpdateRequest ( lastStmtIdWriteOpTime , oplogLastStmtIdWriteDate , txnState ) ; <nl> <nl> - ul . unlock ( ) ; <nl> - <nl> repl : : UnreplicatedWritesBlock doNotReplicateWrites ( opCtx ) ; <nl> <nl> updateSessionEntry ( opCtx , updateRequest ) ; <nl> - _registerUpdateCacheOnCommit ( std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ) ; <nl> + _registerUpdateCacheOnCommit ( opCtx , std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _invalidate ( WithLock ) { <nl> - _isValid = false ; <nl> - _activeTxnNumber = kUninitializedTxnNumber ; <nl> - _lastWriteOpTime = repl : : OpTime ( ) ; <nl> + void TransactionParticipant : : Participant : : _invalidate ( WithLock wl ) { <nl> + p ( ) . isValid = false ; <nl> + o ( wl ) . activeTxnNumber = kUninitializedTxnNumber ; <nl> + o ( wl ) . lastWriteOpTime = repl : : OpTime ( ) ; <nl> <nl> / / Reset the transactions metrics . <nl> - stdx : : lock_guard < stdx : : mutex > lm ( _metricsMutex ) ; <nl> - _transactionMetricsObserver . resetSingleTransactionStats ( _activeTxnNumber ) ; <nl> + o ( wl ) . transactionMetricsObserver . resetSingleTransactionStats ( o ( ) . activeTxnNumber ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _resetRetryableWriteState ( WithLock ) { <nl> - _activeTxnCommittedStatements . clear ( ) ; <nl> - _hasIncompleteHistory = false ; <nl> + void TransactionParticipant : : Participant : : _resetRetryableWriteState ( ) { <nl> + p ( ) . activeTxnCommittedStatements . clear ( ) ; <nl> + p ( ) . hasIncompleteHistory = false ; <nl> } <nl> <nl> - void TransactionParticipant : : _resetTransactionState ( WithLock wl , <nl> - TransactionState : : StateFlag state ) { <nl> + void TransactionParticipant : : Participant : : _resetTransactionState ( <nl> + WithLock wl , TransactionState : : StateFlag state ) { <nl> / / If we are transitioning to kNone , we are either starting a new transaction or aborting a <nl> / / prepared transaction for rollback . In the latter case , we will need to relax the invariant <nl> / / that prevents transitioning from kPrepared to kNone . <nl> - if ( _txnState . isPrepared ( wl ) & & state = = TransactionState : : kNone ) { <nl> - _txnState . transitionTo ( <nl> - wl , state , TransactionState : : TransitionValidation : : kRelaxTransitionValidation ) ; <nl> + if ( o ( ) . txnState . isPrepared ( ) & & state = = TransactionState : : kNone ) { <nl> + o ( wl ) . txnState . transitionTo ( <nl> + state , TransactionState : : TransitionValidation : : kRelaxTransitionValidation ) ; <nl> } else { <nl> - _txnState . transitionTo ( wl , state ) ; <nl> + o ( wl ) . txnState . transitionTo ( state ) ; <nl> } <nl> <nl> - _transactionOperationBytes = 0 ; <nl> - _transactionOperations . clear ( ) ; <nl> - _prepareOpTime = repl : : OpTime ( ) ; <nl> - _oldestOplogEntryOpTime = boost : : none ; <nl> - _finishOpTime = boost : : none ; <nl> - _speculativeTransactionReadOpTime = repl : : OpTime ( ) ; <nl> - _multikeyPathInfo . clear ( ) ; <nl> - _autoCommit = boost : : none ; <nl> + p ( ) . transactionOperationBytes = 0 ; <nl> + p ( ) . transactionOperations . clear ( ) ; <nl> + o ( wl ) . prepareOpTime = repl : : OpTime ( ) ; <nl> + p ( ) . oldestOplogEntryOpTime = boost : : none ; <nl> + p ( ) . finishOpTime = boost : : none ; <nl> + p ( ) . speculativeTransactionReadOpTime = repl : : OpTime ( ) ; <nl> + p ( ) . multikeyPathInfo . clear ( ) ; <nl> + p ( ) . autoCommit = boost : : none ; <nl> <nl> / / Release any locks held by this participant and abort the storage transaction . <nl> - _txnResourceStash = boost : : none ; <nl> + o ( wl ) . txnResourceStash = boost : : none ; <nl> } <nl> <nl> - void TransactionParticipant : : invalidate ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> + void TransactionParticipant : : Participant : : invalidate ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> <nl> uassert ( ErrorCodes : : PreparedTransactionInProgress , <nl> " Cannot invalidate prepared transaction " , <nl> - ! _txnState . isInSet ( <nl> - lg , TransactionState : : kPrepared | TransactionState : : kCommittingWithPrepare ) ) ; <nl> + ! o ( ) . txnState . isInSet ( TransactionState : : kPrepared | <nl> + TransactionState : : kCommittingWithPrepare ) ) ; <nl> <nl> / / Invalidate the session and clear both the retryable writes and transactional states on <nl> / / this participant . <nl> _invalidate ( lg ) ; <nl> - _resetRetryableWriteState ( lg ) ; <nl> + _resetRetryableWriteState ( ) ; <nl> _resetTransactionState ( lg , TransactionState : : kNone ) ; <nl> } <nl> <nl> - void TransactionParticipant : : abortPreparedTransactionForRollback ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> + void TransactionParticipant : : Participant : : abortPreparedTransactionForRollback ( <nl> + OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> <nl> / / Invalidate the session . <nl> _invalidate ( lg ) ; <nl> void TransactionParticipant : : abortPreparedTransactionForRollback ( ) { <nl> uassert ( 51030 , <nl> str : : stream ( ) < < " Cannot call abortPreparedTransactionForRollback on unprepared " <nl> < < " transaction . " , <nl> - _txnState . isPrepared ( lg ) ) ; <nl> + o ( ) . txnState . isPrepared ( ) ) ; <nl> <nl> / / It should be safe to clear transactionOperationBytes and transactionOperations because <nl> / / we only modify these variables when adding an operation to a transaction . Since this <nl> void TransactionParticipant : : abortPreparedTransactionForRollback ( ) { <nl> _resetTransactionState ( lg , TransactionState : : kNone ) ; <nl> } <nl> <nl> - repl : : OpTime TransactionParticipant : : getLastWriteOpTime ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - return _lastWriteOpTime ; <nl> - } <nl> - <nl> - boost : : optional < repl : : OplogEntry > TransactionParticipant : : checkStatementExecuted ( <nl> - StmtId stmtId ) const { <nl> + boost : : optional < repl : : OplogEntry > TransactionParticipant : : Participant : : checkStatementExecuted ( <nl> + OperationContext * opCtx , StmtId stmtId ) const { <nl> const auto stmtTimestamp = _checkStatementExecuted ( stmtId ) ; <nl> <nl> if ( ! stmtTimestamp ) <nl> boost : : optional < repl : : OplogEntry > TransactionParticipant : : checkStatementExecuted <nl> <nl> TransactionHistoryIterator txnIter ( * stmtTimestamp ) ; <nl> while ( txnIter . hasNext ( ) ) { <nl> - const auto entry = txnIter . next ( _opCtx ( ) ) ; <nl> + const auto entry = txnIter . next ( opCtx ) ; <nl> invariant ( entry . getStatementId ( ) ) ; <nl> if ( * entry . getStatementId ( ) = = stmtId ) <nl> return entry ; <nl> boost : : optional < repl : : OplogEntry > TransactionParticipant : : checkStatementExecuted <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl> - bool TransactionParticipant : : checkStatementExecutedNoOplogEntryFetch ( StmtId stmtId ) const { <nl> + bool TransactionParticipant : : Participant : : checkStatementExecutedNoOplogEntryFetch ( <nl> + StmtId stmtId ) const { <nl> return bool ( _checkStatementExecuted ( stmtId ) ) ; <nl> } <nl> <nl> - void TransactionParticipant : : _checkValid ( WithLock ) const { <nl> - uassert ( ErrorCodes : : ConflictingOperationInProgress , <nl> - str : : stream ( ) < < " Session " < < _sessionId ( ) <nl> - < < " was concurrently modified and the operation must be retried . " , <nl> - _isValid ) ; <nl> - } <nl> - <nl> - void TransactionParticipant : : _checkIsActiveTransaction ( WithLock , TxnNumber txnNumber ) const { <nl> - uassert ( ErrorCodes : : ConflictingOperationInProgress , <nl> - str : : stream ( ) < < " Cannot perform operations on transaction " < < txnNumber <nl> - < < " on session " <nl> - < < _sessionId ( ) <nl> - < < " because a different transaction " <nl> - < < _activeTxnNumber <nl> - < < " is now active . " , <nl> - txnNumber = = _activeTxnNumber ) ; <nl> - } <nl> - <nl> - boost : : optional < repl : : OpTime > TransactionParticipant : : _checkStatementExecuted ( StmtId stmtId ) const { <nl> - invariant ( _isValid ) ; <nl> + boost : : optional < repl : : OpTime > TransactionParticipant : : Participant : : _checkStatementExecuted ( <nl> + StmtId stmtId ) const { <nl> + invariant ( p ( ) . isValid ) ; <nl> <nl> - const auto it = _activeTxnCommittedStatements . find ( stmtId ) ; <nl> - if ( it = = _activeTxnCommittedStatements . end ( ) ) { <nl> + const auto it = p ( ) . activeTxnCommittedStatements . find ( stmtId ) ; <nl> + if ( it = = p ( ) . activeTxnCommittedStatements . end ( ) ) { <nl> uassert ( ErrorCodes : : IncompleteTransactionHistory , <nl> - str : : stream ( ) < < " Incomplete history detected for transaction " < < _activeTxnNumber <nl> + str : : stream ( ) < < " Incomplete history detected for transaction " <nl> + < < o ( ) . activeTxnNumber <nl> < < " on session " <nl> < < _sessionId ( ) , <nl> - ! _hasIncompleteHistory ) ; <nl> + ! p ( ) . hasIncompleteHistory ) ; <nl> <nl> return boost : : none ; <nl> } <nl> boost : : optional < repl : : OpTime > TransactionParticipant : : _checkStatementExecuted ( St <nl> return it - > second ; <nl> } <nl> <nl> - UpdateRequest TransactionParticipant : : _makeUpdateRequest ( <nl> + UpdateRequest TransactionParticipant : : Participant : : _makeUpdateRequest ( <nl> const repl : : OpTime & newLastWriteOpTime , <nl> Date_t newLastWriteDate , <nl> boost : : optional < DurableTxnStateEnum > newState ) const { <nl> UpdateRequest TransactionParticipant : : _makeUpdateRequest ( <nl> const auto updateBSON = [ & ] { <nl> SessionTxnRecord newTxnRecord ; <nl> newTxnRecord . setSessionId ( _sessionId ( ) ) ; <nl> - newTxnRecord . setTxnNum ( _activeTxnNumber ) ; <nl> + newTxnRecord . setTxnNum ( o ( ) . activeTxnNumber ) ; <nl> newTxnRecord . setLastWriteOpTime ( newLastWriteOpTime ) ; <nl> newTxnRecord . setLastWriteDate ( newLastWriteDate ) ; <nl> newTxnRecord . setState ( newState ) ; <nl> UpdateRequest TransactionParticipant : : _makeUpdateRequest ( <nl> return updateRequest ; <nl> } <nl> <nl> - void TransactionParticipant : : _registerUpdateCacheOnCommit ( <nl> - std : : vector < StmtId > stmtIdsWritten , const repl : : OpTime & lastStmtIdWriteOpTime ) { <nl> - _opCtx ( ) - > recoveryUnit ( ) - > onCommit ( <nl> - [ this , stmtIdsWritten = std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ] ( <nl> + void TransactionParticipant : : Participant : : _registerUpdateCacheOnCommit ( <nl> + OperationContext * opCtx , <nl> + std : : vector < StmtId > stmtIdsWritten , <nl> + const repl : : OpTime & lastStmtIdWriteOpTime ) { <nl> + opCtx - > recoveryUnit ( ) - > onCommit ( <nl> + [ opCtx , stmtIdsWritten = std : : move ( stmtIdsWritten ) , lastStmtIdWriteOpTime ] ( <nl> boost : : optional < Timestamp > ) { <nl> - invariant ( _isValid ) ; <nl> + TransactionParticipant : : Participant participant ( opCtx ) ; <nl> + invariant ( participant . p ( ) . isValid ) ; <nl> <nl> - RetryableWritesStats : : get ( getGlobalServiceContext ( ) ) <nl> + RetryableWritesStats : : get ( opCtx - > getServiceContext ( ) ) <nl> - > incrementTransactionsCollectionWriteCount ( ) ; <nl> <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> + stdx : : lock_guard < Client > lg ( * opCtx - > getClient ( ) ) ; <nl> <nl> / / The cache of the last written record must always be advanced after a write so that <nl> / / subsequent writes have the correct point to start from . <nl> - _lastWriteOpTime = lastStmtIdWriteOpTime ; <nl> + participant . o ( lg ) . lastWriteOpTime = lastStmtIdWriteOpTime ; <nl> <nl> for ( const auto stmtId : stmtIdsWritten ) { <nl> if ( stmtId = = kIncompleteHistoryStmtId ) { <nl> - _hasIncompleteHistory = true ; <nl> + participant . p ( ) . hasIncompleteHistory = true ; <nl> continue ; <nl> } <nl> <nl> - const auto insertRes = <nl> - _activeTxnCommittedStatements . emplace ( stmtId , lastStmtIdWriteOpTime ) ; <nl> + const auto insertRes = participant . p ( ) . activeTxnCommittedStatements . emplace ( <nl> + stmtId , lastStmtIdWriteOpTime ) ; <nl> if ( ! insertRes . second ) { <nl> const auto & existingOpTime = insertRes . first - > second ; <nl> - fassertOnRepeatedExecution ( _sessionId ( ) , <nl> - _activeTxnNumber , <nl> + fassertOnRepeatedExecution ( participant . _sessionId ( ) , <nl> + participant . o ( ) . activeTxnNumber , <nl> stmtId , <nl> existingOpTime , <nl> lastStmtIdWriteOpTime ) ; <nl> void TransactionParticipant : : _registerUpdateCacheOnCommit ( <nl> <nl> const auto closeConnectionElem = data [ " closeConnection " ] ; <nl> if ( closeConnectionElem . eoo ( ) | | closeConnectionElem . Bool ( ) ) { <nl> - _opCtx ( ) - > getClient ( ) - > session ( ) - > end ( ) ; <nl> + opCtx - > getClient ( ) - > session ( ) - > end ( ) ; <nl> } <nl> <nl> const auto failBeforeCommitExceptionElem = data [ " failBeforeCommitExceptionCode " ] ; <nl> void TransactionParticipant : : _registerUpdateCacheOnCommit ( <nl> const auto failureCode = ErrorCodes : : Error ( int ( failBeforeCommitExceptionElem . Number ( ) ) ) ; <nl> uasserted ( failureCode , <nl> str : : stream ( ) < < " Failing write for " < < _sessionId ( ) < < " : " <nl> - < < _activeTxnNumber <nl> + < < o ( ) . activeTxnNumber <nl> < < " due to failpoint . The write must not be reflected . " ) ; <nl> } <nl> } <nl> mmm a / src / mongo / db / transaction_participant . h <nl> ppp b / src / mongo / db / transaction_participant . h <nl> <nl> # include " mongo / db / repl / oplog_entry . h " <nl> # include " mongo / db / repl / read_concern_args . h " <nl> # include " mongo / db / session . h " <nl> + # include " mongo / db / session_catalog . h " <nl> # include " mongo / db / session_txn_record_gen . h " <nl> # include " mongo / db / single_transaction_stats . h " <nl> # include " mongo / db / storage / recovery_unit . h " <nl> enum class TerminationCause { <nl> } ; <nl> <nl> / * * <nl> - * A state machine that coordinates a distributed transaction commit with the transaction <nl> - * coordinator . <nl> + * This class maintains the state of a transaction running on a server session . It can only exist as <nl> + * a decoration on the Session object and its state can only be modified by the thread which has the <nl> + * session checked - out . <nl> + * <nl> + * Its methods are split in two groups with distinct read / write and concurrency control rules . See <nl> + * the comments below for more information . <nl> * / <nl> class TransactionParticipant { <nl> MONGO_DISALLOW_COPYING ( TransactionParticipant ) ; <nl> <nl> + struct PrivateState ; <nl> + struct ObservableState ; <nl> + <nl> + / * * <nl> + * Indicates the state of the current multi - document transaction , if any . If the transaction is <nl> + * in any state but kInProgress , no more operations can be collected . Once the transaction is in <nl> + * kPrepared , the transaction is not allowed to abort outside of an ' abortTransaction ' command . <nl> + * At this point , aborting the transaction must log an ' abortTransaction ' oplog entry . <nl> + * / <nl> + class TransactionState { <nl> + public : <nl> + enum StateFlag { <nl> + kNone = 1 < < 0 , <nl> + kInProgress = 1 < < 1 , <nl> + kPrepared = 1 < < 2 , <nl> + kCommittingWithoutPrepare = 1 < < 3 , <nl> + kCommittingWithPrepare = 1 < < 4 , <nl> + kCommitted = 1 < < 5 , <nl> + kAbortedWithoutPrepare = 1 < < 6 , <nl> + kAbortedWithPrepare = 1 < < 7 <nl> + } ; <nl> + <nl> + using StateSet = int ; <nl> + bool isInSet ( StateSet stateSet ) const { <nl> + return _state & stateSet ; <nl> + } <nl> + <nl> + / * * <nl> + * Transitions the session from the current state to the new state . If transition validation <nl> + * is not relaxed , invariants if the transition is illegal . <nl> + * / <nl> + enum class TransitionValidation { kValidateTransition , kRelaxTransitionValidation } ; <nl> + void transitionTo ( <nl> + StateFlag newState , <nl> + TransitionValidation shouldValidate = TransitionValidation : : kValidateTransition ) ; <nl> + <nl> + bool inMultiDocumentTransaction ( ) const { <nl> + return _state = = kInProgress | | _state = = kPrepared ; <nl> + } <nl> + <nl> + bool isNone ( ) const { <nl> + return _state = = kNone ; <nl> + } <nl> + <nl> + bool isInProgress ( ) const { <nl> + return _state = = kInProgress ; <nl> + } <nl> + <nl> + bool isPrepared ( ) const { <nl> + return _state = = kPrepared ; <nl> + } <nl> + <nl> + bool isCommittingWithoutPrepare ( ) const { <nl> + return _state = = kCommittingWithoutPrepare ; <nl> + } <nl> + <nl> + bool isCommittingWithPrepare ( ) const { <nl> + return _state = = kCommittingWithPrepare ; <nl> + } <nl> + <nl> + bool isCommitted ( ) const { <nl> + return _state = = kCommitted ; <nl> + } <nl> + <nl> + bool isAborted ( ) const { <nl> + return _state = = kAbortedWithPrepare | | _state = = kAbortedWithoutPrepare ; <nl> + } <nl> + <nl> + std : : string toString ( ) const { <nl> + return toString ( _state ) ; <nl> + } <nl> + <nl> + static std : : string toString ( StateFlag state ) ; <nl> + <nl> + private : <nl> + static bool _isLegalTransition ( StateFlag oldState , StateFlag newState ) ; <nl> + <nl> + StateFlag _state = kNone ; <nl> + } ; <nl> + <nl> public : <nl> / * * <nl> * Holds state for a snapshot read or multi - statement transaction in between network <nl> class TransactionParticipant { <nl> <nl> / * * <nl> * Stashes transaction state from ' opCtx ' in the newly constructed TxnResources . <nl> - * Ephemerally holds the Client lock associated with opCtx . <nl> + * Caller must hold the Client lock associated with opCtx , attested by WithLock . <nl> * / <nl> - TxnResources ( OperationContext * opCtx , StashStyle stashStyle ) ; <nl> + TxnResources ( WithLock , OperationContext * opCtx , StashStyle stashStyle ) noexcept ; <nl> ~ TxnResources ( ) ; <nl> <nl> / / Rule of 5 : because we have a class - defined destructor , we need to explictly specify <nl> class TransactionParticipant { <nl> SideTransactionBlock ( OperationContext * opCtx ) ; <nl> ~ SideTransactionBlock ( ) ; <nl> <nl> - / / Rule of 5 : because we have a class - defined destructor , we need to explictly specify <nl> - / / the move operator and move assignment operator . <nl> - SideTransactionBlock ( SideTransactionBlock & & ) = default ; <nl> - SideTransactionBlock & operator = ( SideTransactionBlock & & ) = default ; <nl> - <nl> private : <nl> boost : : optional < TxnResources > _txnResources ; <nl> OperationContext * _opCtx ; <nl> class TransactionParticipant { <nl> <nl> static const BSONObj kDeadEndSentinel ; <nl> <nl> - TransactionParticipant ( ) ; <nl> - ~ TransactionParticipant ( ) ; <nl> - <nl> / * * <nl> - * Obtains the transaction participant from a session and a syntactic sugar variant , which <nl> - * obtains it from an operation context on which the session has been checked - out . <nl> + * Class used by observers to examine the state of a TransactionParticipant . <nl> * / <nl> - static TransactionParticipant * get ( OperationContext * opCtx ) ; <nl> - static TransactionParticipant * get ( Session * session ) ; <nl> + class Observer { <nl> + public : <nl> + explicit Observer ( const ObservableSession & session ) ; <nl> <nl> - / * * <nl> - * When the server returns a NoSuchTransaction error for a command , it performs a noop write if <nl> - * there is a writeConcern on the command . The TransientTransactionError label is only appended <nl> - * to a NoSuchTransaction response for ' commitTransaction ' and ' coordinateCommitTransaction ' if <nl> - * there is no writeConcern error . This ensures that if ' commitTransaction ' or <nl> - * ' coordinateCommitTransaction ' is run with w : majority , then the TransientTransactionError <nl> - * label is only returned if the transaction is not committed on any valid branch of history , <nl> - * so the driver or application can safely retry the entire transaction . <nl> - * / <nl> - static void performNoopWriteForNoSuchTransaction ( OperationContext * opCtx ) ; <nl> + / * * <nl> + * Returns the currently active transaction number on this participant . <nl> + * / <nl> + TxnNumber getActiveTxnNumber ( ) const { <nl> + return o ( ) . activeTxnNumber ; <nl> + } <nl> <nl> - / * * <nl> - * Blocking method , which loads the transaction state from storage if it has been marked as <nl> - * needing refresh . <nl> - * <nl> - * In order to avoid the possibility of deadlock , this method must not be called while holding a <nl> - * lock . <nl> - * / <nl> - void refreshFromStorageIfNeeded ( ) ; <nl> + / * * <nl> + * Returns the op time of the last committed write for this session and transaction . If no <nl> + * write has completed yet , returns an empty timestamp . <nl> + * / <nl> + repl : : OpTime getLastWriteOpTime ( ) const { <nl> + return o ( ) . lastWriteOpTime ; <nl> + } <nl> <nl> - / * * <nl> - * Starts a new transaction ( and if the txnNumber is newer aborts any in - progress transaction on <nl> - * the session ) , or continues an already active transaction . <nl> - * <nl> - * ' autocommit ' comes from the ' autocommit ' field in the original client request . The only valid <nl> - * values are boost : : none ( meaning no autocommit was specified ) and false ( meaning that this is <nl> - * the beginning of a multi - statement transaction ) . <nl> - * <nl> - * ' startTransaction ' comes from the ' startTransaction ' field in the original client request . <nl> - * See below for the acceptable values and the meaning of the combinations of autocommit and <nl> - * startTransaction . <nl> - * <nl> - * autocommit = boost : : none , startTransaction = boost : : none : Means retryable write <nl> - * autocommit = false , startTransaction = boost : : none : Means continuation of a multi - statement <nl> - * transaction <nl> - * autocommit = false , startTransaction = true : Means abort whatever transaction is in progress <nl> - * on the session and start a new transaction <nl> - * <nl> - * Any combination other than the ones listed above will invariant since it is expected that the <nl> - * caller has performed the necessary customer input validations . <nl> - * <nl> - * Exceptions of note , which can be thrown are : <nl> - * - TransactionTooOld - if attempt is made to start a transaction older than the currently <nl> - * active one or the last one which committed <nl> - * - PreparedTransactionInProgress - if the transaction is in the prepared state and a new <nl> - * transaction or retryable write is attempted <nl> - * / <nl> - void beginOrContinue ( TxnNumber txnNumber , <nl> - boost : : optional < bool > autocommit , <nl> - boost : : optional < bool > startTransaction ) ; <nl> + / * * <nl> + * Returns the prepare op time that was selected for the transaction , which can be Null if <nl> + * the transaction is not prepared . <nl> + * / <nl> + repl : : OpTime getPrepareOpTime ( ) const { <nl> + return o ( ) . prepareOpTime ; <nl> + } <nl> <nl> - / * * <nl> - * Used only by the secondary oplog application logic . Equivalent to ' beginOrContinue ( txnNumber , <nl> - * false , true ) ' without performing any checks for whether the new txnNumber will start a <nl> - * transaction number in the past . <nl> - * <nl> - * NOTE : This method assumes that there are no concurrent users of the transaction since it <nl> - * unconditionally changes the active transaction on the session . <nl> - * / <nl> - void beginOrContinueTransactionUnconditionally ( TxnNumber txnNumber ) ; <nl> + / * * <nl> + * Returns whether the transaction has exceeded its expiration time . <nl> + * / <nl> + bool expiredAsOf ( Date_t when ) const ; <nl> <nl> - / * * <nl> - * Transfers management of transaction resources from the OperationContext to the Session . <nl> - * / <nl> - void stashTransactionResources ( OperationContext * opCtx ) ; <nl> + / * * <nl> + * Returns whether we are in a multi - document transaction , which means we have an active <nl> + * transaction which has autocommit : false and has not been committed or aborted . It is <nl> + * possible that the current transaction is stashed onto the stack via a <nl> + * ` SideTransactionBlock ` . <nl> + * / <nl> + bool inMultiDocumentTransaction ( ) const { <nl> + return o ( ) . txnState . inMultiDocumentTransaction ( ) ; <nl> + } ; <nl> <nl> - / * * <nl> - * Transfers management of transaction resources from the Session to the OperationContext . <nl> - * / <nl> - void unstashTransactionResources ( OperationContext * opCtx , const std : : string & cmdName ) ; <nl> + bool transactionIsCommitted ( ) const { <nl> + return o ( ) . txnState . isCommitted ( ) ; <nl> + } <nl> <nl> - / * * <nl> - * Puts a transaction into a prepared state and returns the prepareTimestamp . <nl> - * <nl> - * On secondary , the " prepareTimestamp " will be given in the oplog . <nl> - * / <nl> - Timestamp prepareTransaction ( OperationContext * opCtx , <nl> - boost : : optional < repl : : OpTime > prepareOptime ) ; <nl> + bool transactionIsAborted ( ) const { <nl> + return o ( ) . txnState . isAborted ( ) ; <nl> + } <nl> <nl> - / * * <nl> - * Commits the transaction , including committing the write unit of work and updating <nl> - * transaction state . <nl> - * <nl> - * Throws an exception if the transaction is prepared . <nl> - * / <nl> - void commitUnpreparedTransaction ( OperationContext * opCtx ) ; <nl> + bool transactionIsPrepared ( ) const { <nl> + return o ( ) . txnState . isPrepared ( ) ; <nl> + } <nl> <nl> - / * * <nl> - * Commits the transaction , including committing the write unit of work and updating <nl> - * transaction state . <nl> - * <nl> - * On a secondary , the " commitOplogEntryOpTime " will be the OpTime of the commitTransaction oplog <nl> - * entry . <nl> - * <nl> - * Throws an exception if the transaction is not prepared or if the ' commitTimestamp ' is null . <nl> - * / <nl> - void commitPreparedTransaction ( OperationContext * opCtx , <nl> - Timestamp commitTimestamp , <nl> - boost : : optional < repl : : OpTime > commitOplogEntryOpTime ) ; <nl> + / * * <nl> + * Returns true if we are in an active multi - document transaction or if the transaction has <nl> + * been aborted . This is used to cover the case where a transaction has been aborted , but <nl> + * the <nl> + * OperationContext state has not been cleared yet . <nl> + * / <nl> + bool inActiveOrKilledMultiDocumentTransaction ( ) const { <nl> + return o ( ) . txnState . inMultiDocumentTransaction ( ) | | o ( ) . txnState . isAborted ( ) ; <nl> + } <nl> <nl> - / * * <nl> - * Aborts the transaction outside the transaction , releasing transaction resources . <nl> - * <nl> - * Not called with session checked out . <nl> - * / <nl> - void abortArbitraryTransaction ( ) ; <nl> - <nl> - / * <nl> - * Aborts the transaction inside the transaction , releasing transaction resources . <nl> - * We ' re inside the transaction when we have the Session checked out and ' opCtx ' owns the <nl> - * transaction resources . <nl> - * Aborts the transaction and releases transaction resources when we have the Session checked <nl> - * out and ' opCtx ' owns the transaction resources . <nl> - * / <nl> - void abortActiveTransaction ( OperationContext * opCtx ) ; <nl> + / * * <nl> + * If this session is holding stashed locks in txnResourceStash , reports the current state <nl> + * of the session using the provided builder . <nl> + * / <nl> + BSONObj reportStashedState ( OperationContext * opCtx ) const ; <nl> + void reportStashedState ( OperationContext * opCtx , BSONObjBuilder * builder ) const ; <nl> <nl> - / * <nl> - * If the transaction is prepared , stash its resources . If not , it ' s the same as <nl> - * abortActiveTransaction . <nl> - * / <nl> - void abortActiveUnpreparedOrStashPreparedTransaction ( OperationContext * opCtx ) ; <nl> + / * * <nl> + * If this session is not holding stashed locks in txnResourceStash ( transaction is active ) , <nl> + * reports the current state of the session using the provided builder . <nl> + * / <nl> + void reportUnstashedState ( OperationContext * opCtx , BSONObjBuilder * builder ) const ; <nl> <nl> - / * * <nl> - * Aborts the storage transaction of the prepared transaction on this participant by releasing <nl> - * its resources . Also invalidates the session and the current transaction state . <nl> - * Avoids writing any oplog entries or making any changes to the transaction table since the <nl> - * state for prepared transactions will be re - constituted during replication recovery . <nl> - * / <nl> - void abortPreparedTransactionForRollback ( ) ; <nl> + protected : <nl> + explicit Observer ( TransactionParticipant * tp ) : _tp ( tp ) { } <nl> <nl> - / * * <nl> - * Adds a stored operation to the list of stored operations for the current multi - document <nl> - * ( non - autocommit ) transaction . It is illegal to add operations when no multi - document <nl> - * transaction is in progress . <nl> - * / <nl> - void addTransactionOperation ( OperationContext * opCtx , const repl : : ReplOperation & operation ) ; <nl> + const TransactionParticipant : : ObservableState & o ( ) const { <nl> + return _tp - > _o ; <nl> + } <nl> <nl> - / * * <nl> - * Returns a reference to the stored operations for a completed multi - document ( non - autocommit ) <nl> - * transaction . " Completed " implies that no more operations will be added to the transaction . <nl> - * It is legal to call this method only when the transaction state is in progress or committed . <nl> - * / <nl> - std : : vector < repl : : ReplOperation > & retrieveCompletedTransactionOperations ( <nl> - OperationContext * opCtx ) ; <nl> + const LogicalSessionId & _sessionId ( ) const ; <nl> <nl> - / * * <nl> - * Clears the stored operations for an multi - document ( non - autocommit ) transaction , marking <nl> - * the transaction as closed . It is illegal to attempt to add operations to the transaction <nl> - * after this is called . <nl> - * / <nl> - void clearOperationsInMemory ( OperationContext * opCtx ) ; <nl> + / / Reports transaction stats for both active and inactive transactions using the provided <nl> + / / builder . <nl> + void _reportTransactionStats ( OperationContext * opCtx , <nl> + BSONObjBuilder * builder , <nl> + repl : : ReadConcernArgs readConcernArgs ) const ; <nl> <nl> - / * * <nl> - * Yield or reacquire locks for prepared transacitons , used on replication state transition . <nl> - * / <nl> - void refreshLocksForPreparedTransaction ( OperationContext * opCtx , bool yieldLocks ) ; <nl> + TransactionParticipant * _tp ; <nl> + } ; / / class Observer <nl> <nl> - / * * <nl> - * May only be called while a multi - document transaction is not committed and adds the multi - key <nl> - * path info to the set of path infos to be updated at commit time . <nl> - * / <nl> - void addUncommittedMultikeyPathInfo ( MultikeyPathInfo info ) { <nl> - invariant ( inMultiDocumentTransaction ( ) ) ; <nl> - _multikeyPathInfo . emplace_back ( std : : move ( info ) ) ; <nl> - } <nl> <nl> / * * <nl> - * May only be called while a mutil - document transaction is not committed and returns the path <nl> - * infos which have been added so far . <nl> + * Class used by a thread that has checked out the TransactionParticipant ' s session to <nl> + * observe and modify the transaction participant . <nl> * / <nl> - const std : : vector < MultikeyPathInfo > & getUncommittedMultikeyPathInfos ( ) const { <nl> - invariant ( inMultiDocumentTransaction ( ) ) ; <nl> - return _multikeyPathInfo ; <nl> - } <nl> + class Participant : public Observer { <nl> + public : <nl> + explicit Participant ( OperationContext * opCtx ) ; <nl> + explicit Participant ( const SessionToKill & session ) ; <nl> <nl> - / * * <nl> - * Called after a write under the specified transaction completes while the node is a primary <nl> - * and specifies the statement ids which were written . Must be called while the caller is still <nl> - * in the write ' s WUOW . Updates the on - disk state of the session to match the specified <nl> - * transaction / opTime and keeps the cached state in sync . <nl> - * <nl> - * ' txnState ' is ' none ' for retryable writes . <nl> - * <nl> - * Must only be called with the session checked - out . <nl> - * <nl> - * Throws if the session has been invalidated or the active transaction number doesn ' t match . <nl> - * / <nl> - void onWriteOpCompletedOnPrimary ( OperationContext * opCtx , <nl> - TxnNumber txnNumber , <nl> - std : : vector < StmtId > stmtIdsWritten , <nl> - const repl : : OpTime & lastStmtIdWriteOpTime , <nl> - Date_t lastStmtIdWriteDate , <nl> - boost : : optional < DurableTxnStateEnum > txnState ) ; <nl> + explicit operator bool ( ) const { <nl> + return _tp ; <nl> + } <nl> <nl> - / * * <nl> - * Called after an entry for the specified session and transaction has been written to the oplog <nl> - * during chunk migration , while the node is still primary . Must be called while the caller is <nl> - * still in the oplog write ' s WUOW . Updates the on - disk state of the session to match the <nl> - * specified transaction / opTime and keeps the cached state in sync . <nl> - * <nl> - * May be called concurrently with onWriteOpCompletedOnPrimary or onMigrateCompletedOnPrimary <nl> - * and doesn ' t require the session to be checked - out . <nl> - * <nl> - * Throws if the session has been invalidated or the active transaction number is newer than the <nl> - * one specified . <nl> - * / <nl> - void onMigrateCompletedOnPrimary ( OperationContext * opCtx , <nl> - TxnNumber txnNumber , <nl> - std : : vector < StmtId > stmtIdsWritten , <nl> - const repl : : OpTime & lastStmtIdWriteOpTime , <nl> - Date_t oplogLastStmtIdWriteDate ) ; <nl> + / * * <nl> + * Blocking method , which loads the transaction state from storage if it has been marked as <nl> + * needing refresh . <nl> + * <nl> + * In order to avoid the possibility of deadlock , this method must not be called while <nl> + * holding a <nl> + * lock . <nl> + * / <nl> + void refreshFromStorageIfNeeded ( OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * Checks whether the given statementId for the specified transaction has already executed and <nl> - * if so , returns the oplog entry which was generated by that write . If the statementId hasn ' t <nl> - * executed , returns boost : : none . <nl> - * <nl> - * Must only be called with the session checked - out . <nl> - * <nl> - * Throws if the session has been invalidated or the active transaction number doesn ' t match . <nl> - * / <nl> - boost : : optional < repl : : OplogEntry > checkStatementExecuted ( StmtId stmtId ) const ; <nl> + / * * <nl> + * Starts a new transaction ( and if the txnNumber is newer aborts any in - progress <nl> + * transaction on <nl> + * the session ) , or continues an already active transaction . <nl> + * <nl> + * ' autocommit ' comes from the ' autocommit ' field in the original client request . The only <nl> + * valid <nl> + * values are boost : : none ( meaning no autocommit was specified ) and false ( meaning that this <nl> + * is <nl> + * the beginning of a multi - statement transaction ) . <nl> + * <nl> + * ' startTransaction ' comes from the ' startTransaction ' field in the original client <nl> + * request . <nl> + * See below for the acceptable values and the meaning of the combinations of autocommit and <nl> + * startTransaction . <nl> + * <nl> + * autocommit = boost : : none , startTransaction = boost : : none : Means retryable write <nl> + * autocommit = false , startTransaction = boost : : none : Means continuation of a <nl> + * multi - statement <nl> + * transaction <nl> + * autocommit = false , startTransaction = true : Means abort whatever transaction is in <nl> + * progress <nl> + * on the session and start a new transaction <nl> + * <nl> + * Any combination other than the ones listed above will invariant since it is expected that <nl> + * the <nl> + * caller has performed the necessary customer input validations . <nl> + * <nl> + * Exceptions of note , which can be thrown are : <nl> + * - TransactionTooOld - if attempt is made to start a transaction older than the <nl> + * currently <nl> + * active one or the last one which committed <nl> + * - PreparedTransactionInProgress - if the transaction is in the prepared state and a new <nl> + * transaction or retryable write is attempted <nl> + * / <nl> + void beginOrContinue ( OperationContext * opCtx , <nl> + TxnNumber txnNumber , <nl> + boost : : optional < bool > autocommit , <nl> + boost : : optional < bool > startTransaction ) ; <nl> <nl> - / * * <nl> - * Checks whether the given statementId for the specified transaction has already executed <nl> - * without fetching the oplog entry which was generated by that write . <nl> - * <nl> - * Must only be called with the session checked - out . <nl> - * <nl> - * Throws if the session has been invalidated or the active transaction number doesn ' t match . <nl> - * / <nl> - bool checkStatementExecutedNoOplogEntryFetch ( StmtId stmtId ) const ; <nl> + / * * <nl> + * Used only by the secondary oplog application logic . Equivalent to <nl> + * ' beginOrContinue ( txnNumber , <nl> + * false , true ) ' without performing any checks for whether the new txnNumber will start a <nl> + * transaction number in the past . <nl> + * / <nl> + void beginOrContinueTransactionUnconditionally ( OperationContext * opCtx , <nl> + TxnNumber txnNumber ) ; <nl> <nl> - / * * <nl> - * Marks the session as requiring refresh . Used when the session state has been modified <nl> - * externally , such as through a direct write to the transactions table . <nl> - * / <nl> - void invalidate ( ) ; <nl> + / * * <nl> + * Transfers management of transaction resources from the currently checked - out <nl> + * OperationContext <nl> + * to the Session . <nl> + * / <nl> + void stashTransactionResources ( OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * Kills the transaction if it is running , ensuring that it releases all resources , even if the <nl> - * transaction is in prepare ( ) . Avoids writing any oplog entries or making any changes to the <nl> - * transaction table . State for prepared transactions will be re - constituted at startup . <nl> - * Note that we don ' t take any active steps to prevent continued use of this <nl> - * TransactionParticipant after shutdown ( ) is called , but we rely on callers to not <nl> - * continue using the TransactionParticipant once we are in shutdown . <nl> - * / <nl> - void shutdown ( ) ; <nl> + / * * <nl> + * Transfers management of transaction resources from the Session to the currently <nl> + * checked - out <nl> + * OperationContext . <nl> + * / <nl> + void unstashTransactionResources ( OperationContext * opCtx , const std : : string & cmdName ) ; <nl> <nl> - / * * <nl> - * Returns the currently active transaction number on this participant . <nl> - * / <nl> - TxnNumber getActiveTxnNumber ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lg ( _mutex ) ; <nl> - return _activeTxnNumber ; <nl> - } <nl> + / * * <nl> + * Puts a transaction into a prepared state and returns the prepareTimestamp . <nl> + * <nl> + * On secondary , the " prepareTimestamp " will be given in the oplog . <nl> + * / <nl> + Timestamp prepareTransaction ( OperationContext * opCtx , <nl> + boost : : optional < repl : : OpTime > prepareOptime ) ; <nl> <nl> - / * * <nl> - * Returns the op time of the last committed write for this session and transaction . If no write <nl> - * has completed yet , returns an empty timestamp . <nl> - * <nl> - * Throws if the session has been invalidated or the active transaction number doesn ' t match . <nl> - * / <nl> - repl : : OpTime getLastWriteOpTime ( ) const ; <nl> + / * * <nl> + * Commits the transaction , including committing the write unit of work and updating <nl> + * transaction state . <nl> + * <nl> + * Throws an exception if the transaction is prepared . <nl> + * / <nl> + void commitUnpreparedTransaction ( OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * Returns the prepare op time that was selected for the transaction , which can be Null if the <nl> - * transaction is not prepared . <nl> - * / <nl> - repl : : OpTime getPrepareOpTime ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _prepareOpTime ; <nl> - } <nl> + / * * <nl> + * Commits the transaction , including committing the write unit of work and updating <nl> + * transaction state . <nl> + * <nl> + * On a secondary , the " commitOplogEntryOpTime " will be the OpTime of the commitTransaction <nl> + * oplog entry . <nl> + * <nl> + * Throws an exception if the transaction is not prepared or if the ' commitTimestamp ' is <nl> + * null . <nl> + * / <nl> + void commitPreparedTransaction ( OperationContext * opCtx , <nl> + Timestamp commitTimestamp , <nl> + boost : : optional < repl : : OpTime > commitOplogEntryOpTime ) ; <nl> <nl> - / * * <nl> - * Returns whether the transaction has exceeded its expiration time . <nl> - * / <nl> - bool expired ( ) const ; <nl> + / * * <nl> + * Aborts the transaction , if it is not in the " prepared " state . <nl> + * / <nl> + void abortTransactionIfNotPrepared ( OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * Returns whether we are in a multi - document transaction , which means we have an active <nl> - * transaction which has autoCommit : false and has not been committed or aborted . It is possible <nl> - * that the current transaction is stashed onto the stack via a ` SideTransactionBlock ` . <nl> - * / <nl> - bool inMultiDocumentTransaction ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _txnState . inMultiDocumentTransaction ( lk ) ; <nl> - } ; <nl> + / * <nl> + * Aborts the transaction , releasing transaction resources . <nl> + * / <nl> + void abortActiveTransaction ( OperationContext * opCtx ) ; <nl> <nl> - bool transactionIsCommitted ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _txnState . isCommitted ( lk ) ; <nl> - } <nl> + / * <nl> + * If the transaction is prepared , stash its resources . If not , it ' s the same as <nl> + * abortActiveTransaction . <nl> + * / <nl> + void abortActiveUnpreparedOrStashPreparedTransaction ( OperationContext * opCtx ) ; <nl> <nl> - bool transactionIsAborted ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _txnState . isAborted ( lk ) ; <nl> - } <nl> + / * * <nl> + * Aborts the storage transaction of the prepared transaction on this participant by <nl> + * releasing its resources . Also invalidates the session and the current transaction state . <nl> + * Avoids writing any oplog entries or making any changes to the transaction table since the <nl> + * state for prepared transactions will be re - constituted during replication recovery . <nl> + * / <nl> + void abortPreparedTransactionForRollback ( OperationContext * opCtx ) ; <nl> <nl> - bool transactionIsPrepared ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _txnState . isPrepared ( lk ) ; <nl> - } <nl> + / * * <nl> + * Adds a stored operation to the list of stored operations for the current multi - document <nl> + * ( non - autocommit ) transaction . It is illegal to add operations when no multi - document <nl> + * transaction is in progress . <nl> + * / <nl> + void addTransactionOperation ( OperationContext * opCtx , const repl : : ReplOperation & operation ) ; <nl> <nl> - / * * <nl> - * Returns true if we are in an active multi - document transaction or if the transaction has <nl> - * been aborted . This is used to cover the case where a transaction has been aborted , but the <nl> - * OperationContext state has not been cleared yet . <nl> - * / <nl> - bool inActiveOrKilledMultiDocumentTransaction ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return ( _txnState . inMultiDocumentTransaction ( lk ) | | _txnState . isAborted ( lk ) ) ; <nl> - } <nl> + / * * <nl> + * Returns a reference to the stored operations for a completed multi - document <nl> + * ( non - autocommit ) transaction . " Completed " implies that no more operations will be added <nl> + * to the transaction . It is legal to call this method only when the transaction state is <nl> + * in progress or committed . <nl> + * / <nl> + std : : vector < repl : : ReplOperation > & retrieveCompletedTransactionOperations ( <nl> + OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * If this session is holding stashed locks in _txnResourceStash , reports the current state of <nl> - * the session using the provided builder . Locks the session object ' s mutex while running . <nl> - * / <nl> - BSONObj reportStashedState ( ) const ; <nl> - void reportStashedState ( BSONObjBuilder * builder ) const ; <nl> + / * * <nl> + * Clears the stored operations for an multi - document ( non - autocommit ) transaction , marking <nl> + * the transaction as closed . It is illegal to attempt to add operations to the transaction <nl> + * after this is called . <nl> + * / <nl> + void clearOperationsInMemory ( OperationContext * opCtx ) ; <nl> <nl> - / * * <nl> - * If this session is not holding stashed locks in _txnResourceStash ( transaction is active ) , <nl> - * reports the current state of the session using the provided builder . Locks the session <nl> - * object ' s mutex while running . <nl> - * <nl> - * If this is called from a thread other than the owner of the opCtx , that thread must be <nl> - * holding the client lock . <nl> - * / <nl> - void reportUnstashedState ( OperationContext * opCtx , BSONObjBuilder * builder ) const ; <nl> - <nl> - / / <nl> - / / Methods used for unit - testing only <nl> - / / <nl> - <nl> - std : : string getTransactionInfoForLogForTest ( <nl> - const SingleThreadedLockStats * lockStats , <nl> - bool committed , <nl> - const repl : : ReadConcernArgs & readConcernArgs ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - TerminationCause terminationCause = <nl> - committed ? TerminationCause : : kCommitted : TerminationCause : : kAborted ; <nl> - return _transactionInfoForLog ( lockStats , terminationCause , readConcernArgs ) ; <nl> - } <nl> + / * * <nl> + * Yield or reacquire locks for prepared transactions , used on replication state transition . <nl> + * / <nl> + void refreshLocksForPreparedTransaction ( OperationContext * opCtx , bool yieldLocks ) ; <nl> <nl> - SingleTransactionStats getSingleTransactionStatsForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _metricsMutex ) ; <nl> - return _transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> - } <nl> + / * * <nl> + * May only be called while a multi - document transaction is not committed and adds the <nl> + * multi - key <nl> + * path info to the set of path infos to be updated at commit time . <nl> + * / <nl> + void addUncommittedMultikeyPathInfo ( MultikeyPathInfo info ) { <nl> + invariant ( inMultiDocumentTransaction ( ) ) ; <nl> + p ( ) . multikeyPathInfo . emplace_back ( std : : move ( info ) ) ; <nl> + } <nl> <nl> - std : : vector < repl : : ReplOperation > getTransactionOperationsForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _transactionOperations ; <nl> - } <nl> + / * * <nl> + * May only be called while a mutil - document transaction is not committed and returns the <nl> + * path <nl> + * infos which have been added so far . <nl> + * / <nl> + const std : : vector < MultikeyPathInfo > & getUncommittedMultikeyPathInfos ( ) const { <nl> + invariant ( inMultiDocumentTransaction ( ) ) ; <nl> + return p ( ) . multikeyPathInfo ; <nl> + } <nl> <nl> - repl : : OpTime getSpeculativeTransactionReadOpTimeForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _speculativeTransactionReadOpTime ; <nl> - } <nl> + / * * <nl> + * Called after a write under the specified transaction completes while the node is a <nl> + * primary <nl> + * and specifies the statement ids which were written . Must be called while the caller is <nl> + * still <nl> + * in the write ' s WUOW . Updates the on - disk state of the session to match the specified <nl> + * transaction / opTime and keeps the cached state in sync . <nl> + * <nl> + * ' txnState ' is ' none ' for retryable writes . <nl> + * <nl> + * Throws if the session has been invalidated or the active transaction number doesn ' t <nl> + * match . <nl> + * / <nl> + void onWriteOpCompletedOnPrimary ( OperationContext * opCtx , <nl> + TxnNumber txnNumber , <nl> + std : : vector < StmtId > stmtIdsWritten , <nl> + const repl : : OpTime & lastStmtIdWriteOpTime , <nl> + Date_t lastStmtIdWriteDate , <nl> + boost : : optional < DurableTxnStateEnum > txnState ) ; <nl> <nl> - boost : : optional < repl : : OpTime > getFinishOpTimeForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _finishOpTime ; <nl> - } <nl> + / * * <nl> + * Called after an entry for the specified session and transaction has been written to the <nl> + * oplog during chunk migration , while the node is still primary . Must be called while the <nl> + * caller is still in the oplog write ' s WUOW . Updates the on - disk state of the session to <nl> + * match the specified transaction / opTime and keeps the cached state in sync . <nl> + * <nl> + * Throws if the session has been invalidated or the active transaction number is newer than <nl> + * the one specified . <nl> + * / <nl> + void onMigrateCompletedOnPrimary ( OperationContext * opCtx , <nl> + TxnNumber txnNumber , <nl> + std : : vector < StmtId > stmtIdsWritten , <nl> + const repl : : OpTime & lastStmtIdWriteOpTime , <nl> + Date_t oplogLastStmtIdWriteDate ) ; <nl> <nl> - boost : : optional < repl : : OpTime > getOldestOplogEntryOpTimeForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - return _oldestOplogEntryOpTime ; <nl> - } <nl> + / * * <nl> + * Checks whether the given statementId for the specified transaction has already executed <nl> + * and if so , returns the oplog entry which was generated by that write . If the statementId <nl> + * hasn ' t executed , returns boost : : none . <nl> + * <nl> + * Throws if the session has been invalidated or the active transaction number doesn ' t <nl> + * match . <nl> + * / <nl> + boost : : optional < repl : : OplogEntry > checkStatementExecuted ( OperationContext * opCtx , <nl> + StmtId stmtId ) const ; <nl> <nl> - const Locker * getTxnResourceStashLockerForTest ( ) const { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - invariant ( _txnResourceStash ) ; <nl> - return _txnResourceStash - > locker ( ) ; <nl> - } <nl> + / * * <nl> + * Checks whether the given statementId for the specified transaction has already executed <nl> + * without fetching the oplog entry which was generated by that write . <nl> + * <nl> + * Throws if the session has been invalidated or the active transaction number doesn ' t <nl> + * match . <nl> + * / <nl> + bool checkStatementExecutedNoOplogEntryFetch ( StmtId stmtId ) const ; <nl> <nl> - void transitionToPreparedforTest ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - _txnState . transitionTo ( lk , TransactionState : : kPrepared ) ; <nl> - } <nl> + / * * <nl> + * Marks the session as requiring refresh . Used when the session state has been modified <nl> + * externally , such as through a direct write to the transactions table . <nl> + * / <nl> + void invalidate ( OperationContext * opCtx ) ; <nl> <nl> - void transitionToCommittingWithPrepareforTest ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - _txnState . transitionTo ( lk , TransactionState : : kCommittingWithPrepare ) ; <nl> - } <nl> + / * * <nl> + * Kills the transaction if it is running , ensuring that it releases all resources , even if <nl> + * the transaction is in prepare ( ) . Avoids writing any oplog entries or making any changes <nl> + * to the transaction table . State for prepared transactions will be re - constituted at <nl> + * startup . Note that we don ' t take any active steps to prevent continued use of this <nl> + * TransactionParticipant after shutdown ( ) is called , but we rely on callers to not continue <nl> + * using the TransactionParticipant once we are in shutdown . <nl> + * / <nl> + void shutdown ( OperationContext * opCtx ) ; <nl> + <nl> + / / <nl> + / / Methods for use in C + + unit tests , only . Beware : these methods may not adhere to the <nl> + / / concurrency control rules . <nl> + / / <nl> + <nl> + std : : string getTransactionInfoForLogForTest ( <nl> + OperationContext * opCtx , <nl> + const SingleThreadedLockStats * lockStats , <nl> + bool committed , <nl> + const repl : : ReadConcernArgs & readConcernArgs ) const { <nl> + <nl> + TerminationCause terminationCause = <nl> + committed ? TerminationCause : : kCommitted : TerminationCause : : kAborted ; <nl> + return _transactionInfoForLog ( opCtx , lockStats , terminationCause , readConcernArgs ) ; <nl> + } <nl> + <nl> + SingleTransactionStats getSingleTransactionStatsForTest ( ) const { <nl> + return o ( ) . transactionMetricsObserver . getSingleTransactionStats ( ) ; <nl> + } <nl> + <nl> + std : : vector < repl : : ReplOperation > getTransactionOperationsForTest ( ) const { <nl> + return p ( ) . transactionOperations ; <nl> + } <nl> + <nl> + repl : : OpTime getSpeculativeTransactionReadOpTimeForTest ( ) const { <nl> + return p ( ) . speculativeTransactionReadOpTime ; <nl> + } <nl> + <nl> + boost : : optional < repl : : OpTime > getOldestOplogEntryOpTimeForTest ( ) const { <nl> + return p ( ) . oldestOplogEntryOpTime ; <nl> + } <nl> + <nl> + boost : : optional < repl : : OpTime > getFinishOpTimeForTest ( ) const { <nl> + return p ( ) . finishOpTime ; <nl> + } <nl> + <nl> + const Locker * getTxnResourceStashLockerForTest ( ) const { <nl> + invariant ( o ( ) . txnResourceStash ) ; <nl> + return o ( ) . txnResourceStash - > locker ( ) ; <nl> + } <nl> + <nl> + void transitionToPreparedforTest ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kPrepared ) ; <nl> + } <nl> + <nl> + void transitionToCommittingWithPrepareforTest ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kCommittingWithPrepare ) ; <nl> + } <nl> <nl> + void transitionToAbortedWithoutPrepareforTest ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kAbortedWithoutPrepare ) ; <nl> + } <nl> + <nl> + void transitionToAbortedWithPrepareforTest ( OperationContext * opCtx ) { <nl> + stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> + o ( lk ) . txnState . transitionTo ( TransactionState : : kAbortedWithPrepare ) ; <nl> + } <nl> <nl> - void transitionToAbortedWithoutPrepareforTest ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - _txnState . transitionTo ( lk , TransactionState : : kAbortedWithoutPrepare ) ; <nl> + private : <nl> + boost : : optional < repl : : OpTime > _checkStatementExecuted ( StmtId stmtId ) const ; <nl> + <nl> + UpdateRequest _makeUpdateRequest ( const repl : : OpTime & newLastWriteOpTime , <nl> + Date_t newLastWriteDate , <nl> + boost : : optional < DurableTxnStateEnum > newState ) const ; <nl> + <nl> + void _registerUpdateCacheOnCommit ( OperationContext * opCtx , <nl> + std : : vector < StmtId > stmtIdsWritten , <nl> + const repl : : OpTime & lastStmtIdWriteTs ) ; <nl> + <nl> + / / Called for speculative transactions to fix the optime of the snapshot to read from . <nl> + void _setSpeculativeTransactionOpTime ( OperationContext * opCtx , <nl> + SpeculativeTransactionOpTime opTimeChoice ) ; <nl> + <nl> + <nl> + / / Like _setSpeculativeTransactionOpTime , but caller chooses timestamp of snapshot <nl> + / / explicitly . <nl> + / / It is up to the caller to ensure that Timestamp is greater than or equal to the <nl> + / / all - committed <nl> + / / optime before calling this method ( e . g . by calling <nl> + / / ReplCoordinator : : waitForOpTimeForRead ) . <nl> + void _setSpeculativeTransactionReadTimestamp ( OperationContext * opCtx , Timestamp timestamp ) ; <nl> + <nl> + / / Finishes committing the multi - document transaction after the storage - transaction has been <nl> + / / committed , the oplog entry has been inserted into the oplog , and the transactions table <nl> + / / has <nl> + / / been updated . <nl> + void _finishCommitTransaction ( OperationContext * opCtx ) ; <nl> + <nl> + / / Commits the storage - transaction on the OperationContext . <nl> + / / <nl> + / / This should be called * without * the Client being locked . <nl> + void _commitStorageTransaction ( OperationContext * opCtx ) ; <nl> + <nl> + / / Stash transaction resources . <nl> + void _stashActiveTransaction ( OperationContext * opCtx ) ; <nl> + <nl> + / / Abort the transaction if it ' s in one of the expected states and clean up the transaction <nl> + / / states associated with the opCtx . <nl> + void _abortActiveTransaction ( OperationContext * opCtx , <nl> + TransactionState : : StateSet expectedStates ) ; <nl> + <nl> + / / Releases stashed transaction resources to abort the transaction on the session . <nl> + void _abortTransactionOnSession ( OperationContext * opCtx ) ; <nl> + <nl> + / / Clean up the transaction resources unstashed on operation context . <nl> + void _cleanUpTxnResourceOnOpCtx ( OperationContext * opCtx , TerminationCause terminationCause ) ; <nl> + <nl> + / / Checks if the command can be run on this transaction based on the state of the <nl> + / / transaction . <nl> + void _checkIsCommandValidWithTxnState ( const TxnNumber & requestTxnNumber , <nl> + const std : : string & cmdName ) const ; <nl> + <nl> + / / Logs the transaction information if it has run slower than the global parameter slowMS . <nl> + / / The <nl> + / / transaction must be committed or aborted when this function is called . <nl> + void _logSlowTransaction ( OperationContext * opCtx , <nl> + const SingleThreadedLockStats * lockStats , <nl> + TerminationCause terminationCause , <nl> + repl : : ReadConcernArgs readConcernArgs ) ; <nl> + <nl> + / / This method returns a string with information about a slow transaction . The format of the <nl> + / / logging string produced should match the format used for slow operation logging . A <nl> + / / transaction must be completed ( committed or aborted ) and a valid LockStats reference must <nl> + / / be <nl> + / / passed in order for this method to be called . <nl> + std : : string _transactionInfoForLog ( OperationContext * opCtx , <nl> + const SingleThreadedLockStats * lockStats , <nl> + TerminationCause terminationCause , <nl> + repl : : ReadConcernArgs readConcernArgs ) const ; <nl> + <nl> + / / Bumps up the transaction number of this transaction and perform the necessary cleanup . <nl> + void _setNewTxnNumber ( OperationContext * opCtx , const TxnNumber & txnNumber ) ; <nl> + <nl> + / / Attempt to begin or retry a retryable write at the given transaction number . <nl> + void _beginOrContinueRetryableWrite ( OperationContext * opCtx , TxnNumber txnNumber ) ; <nl> + <nl> + / / Attempt to begin a new multi document transaction at the given transaction number . <nl> + void _beginMultiDocumentTransaction ( OperationContext * opCtx , TxnNumber txnNumber ) ; <nl> + <nl> + / / Attempt to continue an in - progress multi document transaction at the given transaction <nl> + / / number . <nl> + void _continueMultiDocumentTransaction ( OperationContext * opCtx , TxnNumber txnNumber ) ; <nl> + <nl> + / / Helper that invalidates the session state and activeTxnNumber . Also resets the single <nl> + / / transaction stats because the session is no longer valid . <nl> + void _invalidate ( WithLock ) ; <nl> + <nl> + / / Helper that resets the retryable writes state . <nl> + void _resetRetryableWriteState ( ) ; <nl> + <nl> + / / Helper that resets the transactional state . This is used when aborting a transaction , <nl> + / / invalidating a transaction , or starting a new transaction . <nl> + void _resetTransactionState ( WithLock wl , TransactionState : : StateFlag state ) ; <nl> + <nl> + / / Helper that updates ServerTransactionsMetrics once a transaction commits . <nl> + void _updateTxnMetricsOnCommit ( OperationContext * opCtx , bool isCommittingWithPrepare ) ; <nl> + <nl> + / / Releases the resources held in * o ( ) . txnResources to the operation context . <nl> + / / o ( ) . txnResources must be engaged prior to calling this . <nl> + void _releaseTransactionResourcesToOpCtx ( OperationContext * opCtx ) ; <nl> + <nl> + TransactionParticipant : : PrivateState & p ( ) { <nl> + return _tp - > _p ; <nl> + } <nl> + const TransactionParticipant : : PrivateState & p ( ) const { <nl> + return _tp - > _p ; <nl> + } <nl> + TransactionParticipant : : ObservableState & o ( WithLock ) { <nl> + return _tp - > _o ; <nl> + } <nl> + using Observer : : o ; <nl> + } ; / / class Participant <nl> + <nl> + static Participant get ( OperationContext * opCtx ) { <nl> + return Participant ( opCtx ) ; <nl> } <nl> <nl> - void transitionToAbortedWithPrepareforTest ( ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( _mutex ) ; <nl> - _txnState . transitionTo ( lk , TransactionState : : kAbortedWithPrepare ) ; <nl> + static Participant get ( const SessionToKill & session ) { <nl> + return Participant ( session ) ; <nl> } <nl> <nl> + static Observer get ( const ObservableSession & osession ) { <nl> + return Observer ( osession ) ; <nl> + } <nl> + <nl> + / * * <nl> + * When the server returns a NoSuchTransaction error for a command , it performs a noop write if <nl> + * there is a writeConcern on the command . The TransientTransactionError label is only appended <nl> + * to a NoSuchTransaction response for ' commitTransaction ' and ' coordinateCommitTransaction ' if <nl> + * there is no writeConcern error . This ensures that if ' commitTransaction ' or <nl> + * ' coordinateCommitTransaction ' is run with w : majority , then the TransientTransactionError <nl> + * label is only returned if the transaction is not committed on any valid branch of history , <nl> + * so the driver or application can safely retry the entire transaction . <nl> + * / <nl> + static void performNoopWriteForNoSuchTransaction ( OperationContext * opCtx ) ; <nl> + <nl> + TransactionParticipant ( ) = default ; <nl> + ~ TransactionParticipant ( ) = default ; <nl> + <nl> private : <nl> / * * <nl> * Reserves a slot in the oplog with an open storage - transaction while it is alive . Reserves the <nl> class TransactionParticipant { <nl> OplogSlotReserver ( OperationContext * opCtx ) ; <nl> ~ OplogSlotReserver ( ) ; <nl> <nl> - / / Rule of 5 : because we have a class - defined destructor , we need to explictly specify <nl> - / / the move operator and move assignment operator . <nl> - OplogSlotReserver ( OplogSlotReserver & & ) = default ; <nl> - OplogSlotReserver & operator = ( OplogSlotReserver & & ) = default ; <nl> - <nl> / * * <nl> * Returns the oplog slot reserved at construction . <nl> * / <nl> class TransactionParticipant { <nl> OplogSlot _oplogSlot ; <nl> } ; <nl> <nl> - / * * <nl> - * Indicates the state of the current multi - document transaction , if any . If the transaction is <nl> - * in any state but kInProgress , no more operations can be collected . Once the transaction is in <nl> - * kPrepared , the transaction is not allowed to abort outside of an ' abortTransaction ' command . <nl> - * At this point , aborting the transaction must log an ' abortTransaction ' oplog entry . <nl> - * / <nl> - class TransactionState { <nl> - public : <nl> - enum StateFlag { <nl> - kNone = 1 < < 0 , <nl> - kInProgress = 1 < < 1 , <nl> - kPrepared = 1 < < 2 , <nl> - kCommittingWithoutPrepare = 1 < < 3 , <nl> - kCommittingWithPrepare = 1 < < 4 , <nl> - kCommitted = 1 < < 5 , <nl> - kAbortedWithoutPrepare = 1 < < 6 , <nl> - kAbortedWithPrepare = 1 < < 7 <nl> - } ; <nl> - <nl> - using StateSet = int ; <nl> - bool isInSet ( WithLock , StateSet stateSet ) const { <nl> - return _state & stateSet ; <nl> - } <nl> - <nl> - / * * <nl> - * Transitions the session from the current state to the new state . If transition validation <nl> - * is not relaxed , invariants if the transition is illegal . <nl> - * / <nl> - enum class TransitionValidation { kValidateTransition , kRelaxTransitionValidation } ; <nl> - void transitionTo ( <nl> - WithLock , <nl> - StateFlag newState , <nl> - TransitionValidation shouldValidate = TransitionValidation : : kValidateTransition ) ; <nl> - <nl> - bool inMultiDocumentTransaction ( WithLock ) const { <nl> - return _state = = kInProgress | | _state = = kPrepared ; <nl> - } <nl> - <nl> - bool isNone ( WithLock ) const { <nl> - return _state = = kNone ; <nl> - } <nl> + friend std : : ostream & operator < < ( std : : ostream & s , TransactionState txnState ) { <nl> + return ( s < < txnState . toString ( ) ) ; <nl> + } <nl> <nl> - bool isInProgress ( WithLock ) const { <nl> - return _state = = kInProgress ; <nl> - } <nl> + friend StringBuilder & operator < < ( StringBuilder & s , TransactionState txnState ) { <nl> + return ( s < < txnState . toString ( ) ) ; <nl> + } <nl> <nl> - bool isPrepared ( WithLock ) const { <nl> - return _state = = kPrepared ; <nl> - } <nl> + / * * <nl> + * State in this struct may be read by methods of Observer or Participant , and may be written by <nl> + * methods of Participant when they acquire the lock on the opCtx ' s Client . Access this inside <nl> + * Observer and Participant using the private o ( ) method for reading and ( Participant only ) the <nl> + * o ( WithLock ) method for writing . <nl> + * / <nl> + struct ObservableState { <nl> + / / Holds transaction resources between network operations . <nl> + boost : : optional < TxnResources > txnResourceStash ; <nl> <nl> - bool isCommittingWithoutPrepare ( WithLock ) const { <nl> - return _state = = kCommittingWithoutPrepare ; <nl> - } <nl> + / / Maintains the transaction state and the transition table for legal state transitions . <nl> + TransactionState txnState ; <nl> <nl> - bool isCommittingWithPrepare ( WithLock ) const { <nl> - return _state = = kCommittingWithPrepare ; <nl> - } <nl> + / / Tracks the last seen txn number for the session and is always > = to the transaction <nl> + / / number in the last written txn record . When it is > than that in the last written txn <nl> + / / record , this means a new transaction has begun on the session , but it hasn ' t yet <nl> + / / performed any writes . <nl> + TxnNumber activeTxnNumber { kUninitializedTxnNumber } ; <nl> <nl> - bool isCommitted ( WithLock ) const { <nl> - return _state = = kCommitted ; <nl> - } <nl> + / / Caches what is known to be the last optime written for the active transaction . <nl> + repl : : OpTime lastWriteOpTime ; <nl> <nl> - bool isAborted ( WithLock ) const { <nl> - return _state = = kAbortedWithoutPrepare | | _state = = kAbortedWithPrepare ; <nl> - } <nl> + / / Set when a snapshot read / transaction begins . Alleviates cache pressure by limiting how <nl> + / / long a snapshot will remain open and available . Checked in combination with _txnState to <nl> + / / determine whether the transaction should be aborted . This is unset until a transaction <nl> + / / begins on the session , and then reset only when new transactions begin . <nl> + boost : : optional < Date_t > transactionExpireDate ; <nl> <nl> - std : : string toString ( ) const { <nl> - return toString ( _state ) ; <nl> - } <nl> + / / Track the prepareOpTime , the OpTime of the ' prepare ' oplog entry for a transaction . <nl> + repl : : OpTime prepareOpTime ; <nl> <nl> - static std : : string toString ( StateFlag state ) ; <nl> + / / Tracks and updates transaction metrics upon the appropriate transaction event . <nl> + TransactionMetricsObserver transactionMetricsObserver ; <nl> + } _o ; <nl> <nl> - private : <nl> - static bool _isLegalTransition ( StateFlag oldState , StateFlag newState ) ; <nl> + / * * <nl> + * State in this struct may be read and written by methods of the Participant , only . It may <nl> + * access the struct via the private p ( ) accessor . No further locking is required in methods <nl> + * of the Participant . <nl> + * / <nl> + struct PrivateState { <nl> + / / Only set if the server is shutting down and it has been ensured that no new requests will <nl> + / / be accepted . Ensures that any transaction resources will not be stashed from the <nl> + / / operation context onto the transaction participant when the session is checked - in so that <nl> + / / locks can automatically get freed . <nl> + bool inShutdown = false ; <nl> <nl> - StateFlag _state = kNone ; <nl> - } ; <nl> + / / Holds oplog data for operations which have been applied in the current multi - document <nl> + / / transaction . <nl> + std : : vector < repl : : ReplOperation > transactionOperations ; <nl> <nl> - friend std : : ostream & operator < < ( std : : ostream & s , TransactionState txnState ) { <nl> - return ( s < < txnState . toString ( ) ) ; <nl> - } <nl> + / / Total size in bytes of all operations within the _transactionOperations vector . <nl> + size_t transactionOperationBytes = 0 ; <nl> <nl> - friend StringBuilder & operator < < ( StringBuilder & s , TransactionState txnState ) { <nl> - return ( s < < txnState . toString ( ) ) ; <nl> - } <nl> + / / The autocommit setting of this transaction . Should always be false for multi - statement <nl> + / / transaction . Currently only needed for diagnostics reporting . <nl> + boost : : optional < bool > autoCommit ; <nl> <nl> - / / Shortcut to obtain the id of the session under which this participant runs <nl> - const LogicalSessionId & _sessionId ( ) const ; <nl> + / / The OpTime a speculative transaction is reading from and also the earliest opTime it <nl> + / / should wait for write concern for on commit . <nl> + repl : : OpTime speculativeTransactionReadOpTime ; <nl> <nl> - / / Shortcut to obtain the currently checked - out operation context under this participant runs <nl> - OperationContext * _opCtx ( ) const ; <nl> + / / Contains uncommitted multi - key path info entries which were modified under this <nl> + / / transaction so they can be applied to subsequent opreations before the transaction <nl> + / / commits <nl> + std : : vector < MultikeyPathInfo > multikeyPathInfo ; <nl> <nl> - / * * <nl> - * Performing any checks based on the in - memory state of the TransactionParticipant requires <nl> - * that the object is fully in sync with its on - disk representation in the transactions table . <nl> - * This method checks that . The object can be out of sync with the on - disk representation either <nl> - * when it was just created , or after invalidate ( ) was called ( which typically happens after a <nl> - * direct write to the transactions table ) . <nl> - * / <nl> - void _checkValid ( WithLock ) const ; <nl> - <nl> - / / Checks that the specified transaction number is the same as the activeTxnNumber . Effectively <nl> - / / a check that the caller operates on the transaction it thinks it is operating on . <nl> - void _checkIsActiveTransaction ( WithLock , TxnNumber txnNumber ) const ; <nl> - <nl> - boost : : optional < repl : : OpTime > _checkStatementExecuted ( StmtId stmtId ) const ; <nl> - <nl> - UpdateRequest _makeUpdateRequest ( const repl : : OpTime & newLastWriteOpTime , <nl> - Date_t newLastWriteDate , <nl> - boost : : optional < DurableTxnStateEnum > newState ) const ; <nl> - <nl> - void _registerUpdateCacheOnCommit ( std : : vector < StmtId > stmtIdsWritten , <nl> - const repl : : OpTime & lastStmtIdWriteTs ) ; <nl> - <nl> - / / Called for speculative transactions to fix the optime of the snapshot to read from . <nl> - void _setSpeculativeTransactionOpTime ( WithLock , <nl> - OperationContext * opCtx , <nl> - SpeculativeTransactionOpTime opTimeChoice ) ; <nl> - <nl> - <nl> - / / Like _setSpeculativeTransactionOpTime , but caller chooses timestamp of snapshot explicitly . <nl> - / / It is up to the caller to ensure that Timestamp is greater than or equal to the all - committed <nl> - / / optime before calling this method ( e . g . by calling ReplCoordinator : : waitForOpTimeForRead ) . <nl> - void _setSpeculativeTransactionReadTimestamp ( WithLock , <nl> - OperationContext * opCtx , <nl> - Timestamp timestamp ) ; <nl> - <nl> - / / Finishes committing the multi - document transaction after the storage - transaction has been <nl> - / / committed , the oplog entry has been inserted into the oplog , and the transactions table has <nl> - / / been updated . <nl> - void _finishCommitTransaction ( WithLock lk , OperationContext * opCtx ) ; <nl> - <nl> - / / Commits the storage - transaction on the OperationContext . <nl> - / / <nl> - / / This should be called * without * the mutex being locked . <nl> - void _commitStorageTransaction ( OperationContext * opCtx ) ; <nl> - <nl> - / / Stash transaction resources . <nl> - void _stashActiveTransaction ( WithLock , OperationContext * opCtx ) ; <nl> - <nl> - / / Abort the transaction if it ' s in one of the expected states and clean up the transaction <nl> - / / states associated with the opCtx . <nl> - void _abortActiveTransaction ( stdx : : unique_lock < stdx : : mutex > lock , <nl> - OperationContext * opCtx , <nl> - TransactionState : : StateSet expectedStates ) ; <nl> - <nl> - / / Releases stashed transaction resources to abort the transaction on the session . <nl> - void _abortTransactionOnSession ( WithLock ) ; <nl> - <nl> - / / Clean up the transaction resources unstashed on operation context . <nl> - void _cleanUpTxnResourceOnOpCtx ( WithLock wl , <nl> - OperationContext * opCtx , <nl> - TerminationCause terminationCause ) ; <nl> - <nl> - / / Checks if the current transaction number of this transaction still matches with the <nl> - / / parent session as well as the transaction number of the current operation context . <nl> - void _checkIsActiveTransaction ( WithLock , <nl> - const TxnNumber & requestTxnNumber , <nl> - bool checkAbort ) const ; <nl> - <nl> - / / Checks if the command can be run on this transaction based on the state of the transaction . <nl> - void _checkIsCommandValidWithTxnState ( WithLock , <nl> - const TxnNumber & requestTxnNumber , <nl> - const std : : string & cmdName ) ; <nl> - <nl> - / / Logs the transaction information if it has run slower than the global parameter slowMS . The <nl> - / / transaction must be committed or aborted when this function is called . <nl> - void _logSlowTransaction ( WithLock wl , <nl> - const SingleThreadedLockStats * lockStats , <nl> - TerminationCause terminationCause , <nl> - repl : : ReadConcernArgs readConcernArgs ) ; <nl> - <nl> - / / This method returns a string with information about a slow transaction . The format of the <nl> - / / logging string produced should match the format used for slow operation logging . A <nl> - / / transaction must be completed ( committed or aborted ) and a valid LockStats reference must be <nl> - / / passed in order for this method to be called . <nl> - std : : string _transactionInfoForLog ( const SingleThreadedLockStats * lockStats , <nl> - TerminationCause terminationCause , <nl> - repl : : ReadConcernArgs readConcernArgs ) const ; <nl> - <nl> - / / Reports transaction stats for both active and inactive transactions using the provided <nl> - / / builder . The lock may be either a lock on _mutex or a lock on _metricsMutex . <nl> - void _reportTransactionStats ( WithLock wl , <nl> - BSONObjBuilder * builder , <nl> - repl : : ReadConcernArgs readConcernArgs ) const ; <nl> - <nl> - / / Bumps up the transaction number of this transaction and perform the necessary cleanup . <nl> - void _setNewTxnNumber ( WithLock wl , const TxnNumber & txnNumber ) ; <nl> - <nl> - / / Attempt to begin or retry a retryable write at the given transaction number . <nl> - void _beginOrContinueRetryableWrite ( WithLock wl , TxnNumber txnNumber ) ; <nl> - <nl> - / / Attempt to begin a new multi document transaction at the given transaction number . <nl> - void _beginMultiDocumentTransaction ( WithLock wl , TxnNumber txnNumber ) ; <nl> - <nl> - / / Attempt to continue an in - progress multi document transaction at the given transaction <nl> - / / number . <nl> - void _continueMultiDocumentTransaction ( WithLock wl , TxnNumber txnNumber ) ; <nl> - <nl> - / / Helper that invalidates the session state and activeTxnNumber . Also resets the single <nl> - / / transaction stats because the session is no longer valid . <nl> - void _invalidate ( WithLock ) ; <nl> - <nl> - / / Helper that resets the retryable writes state . <nl> - void _resetRetryableWriteState ( WithLock ) ; <nl> - <nl> - / / Helper that resets the transactional state . This is used when aborting a transaction , <nl> - / / invalidating a transaction , or starting a new transaction . <nl> - void _resetTransactionState ( WithLock wl , TransactionState : : StateFlag state ) ; <nl> - <nl> - / / Protects the member variables below . <nl> - mutable stdx : : mutex _mutex ; <nl> - <nl> - / / Holds transaction resources between network operations . <nl> - boost : : optional < TxnResources > _txnResourceStash ; <nl> - <nl> - / / Maintains the transaction state and the transition table for legal state transitions . <nl> - TransactionState _txnState ; <nl> - <nl> - / / Holds oplog data for operations which have been applied in the current multi - document <nl> - / / transaction . <nl> - std : : vector < repl : : ReplOperation > _transactionOperations ; <nl> - <nl> - / / Total size in bytes of all operations within the _transactionOperations vector . <nl> - size_t _transactionOperationBytes = 0 ; <nl> - <nl> - / / Tracks the last seen txn number for the session and is always > = to the transaction number in <nl> - / / the last written txn record . When it is > than that in the last written txn record , this <nl> - / / means a new transaction has begun on the session , but it hasn ' t yet performed any writes . <nl> - TxnNumber _activeTxnNumber { kUninitializedTxnNumber } ; <nl> - <nl> - / / Caches what is known to be the last optime written for the active transaction . <nl> - repl : : OpTime _lastWriteOpTime ; <nl> - <nl> - / / Set when a snapshot read / transaction begins . Alleviates cache pressure by limiting how long <nl> - / / a snapshot will remain open and available . Checked in combination with _txnState to determine <nl> - / / whether the transaction should be aborted . <nl> - / / This is unset until a transaction begins on the session , and then reset only when new <nl> - / / transactions begin . <nl> - boost : : optional < Date_t > _transactionExpireDate ; <nl> - <nl> - / / The autoCommit setting of this transaction . Should always be false for multi - statement <nl> - / / transaction . Currently only needed for diagnostics reporting . <nl> - boost : : optional < bool > _autoCommit ; <nl> - <nl> - / / Track the prepareOpTime , the OpTime of the ' prepare ' oplog entry for a transaction . <nl> - repl : : OpTime _prepareOpTime ; <nl> - <nl> - / / The OpTime a speculative transaction is reading from and also the earliest opTime it <nl> - / / should wait for write concern for on commit . <nl> - repl : : OpTime _speculativeTransactionReadOpTime ; <nl> - <nl> - / / Contains uncommitted multi - key path info entries which were modified under this transaction <nl> - / / so they can be applied to subsequent opreations before the transaction commits <nl> - std : : vector < MultikeyPathInfo > _multikeyPathInfo ; <nl> - <nl> - / / Tracks the OpTime of the first oplog entry written by this TransactionParticipant . <nl> - boost : : optional < repl : : OpTime > _oldestOplogEntryOpTime ; <nl> - <nl> - / / Tracks the OpTime of the abort / commit oplog entry associated with this transaction . <nl> - boost : : optional < repl : : OpTime > _finishOpTime ; <nl> - <nl> - / / Protects _transactionMetricsObserver . The concurrency rules are that const methods on <nl> - / / _transactionMetricsObserver may be called under either _mutex or _metricsMutex , but for <nl> - / / non - const methods , both mutexes must be held , with _mutex being taken before _metricsMutex . <nl> - / / No other locks , particularly including the Client lock , may be taken while holding <nl> - / / _metricsMutex . <nl> - mutable stdx : : mutex _metricsMutex ; <nl> - <nl> - / / Tracks and updates transaction metrics upon the appropriate transaction event . <nl> - TransactionMetricsObserver _transactionMetricsObserver ; <nl> + / / Tracks the OpTime of the first oplog entry written by this TransactionParticipant . <nl> + boost : : optional < repl : : OpTime > oldestOplogEntryOpTime ; <nl> <nl> - / / Only set if the server is shutting down and it has been ensured that no new requests will be <nl> - / / accepted . Ensures that any transaction resources will not be stashed from the operation <nl> - / / context onto the transaction participant when the session is checked - in so that locks can <nl> - / / automatically get freed . <nl> - bool _inShutdown { false } ; <nl> + / / Tracks the OpTime of the abort / commit oplog entry associated with this transaction . <nl> + boost : : optional < repl : : OpTime > finishOpTime ; <nl> <nl> - / / <nl> - / / Retryable writes state <nl> - / / <nl> + / / <nl> + / / Retryable writes state <nl> + / / <nl> <nl> - / / Specifies whether the session information needs to be refreshed from storage <nl> - bool _isValid { false } ; <nl> + / / Specifies whether the session information needs to be refreshed from storage <nl> + bool isValid { false } ; <nl> <nl> - / / Set to true if incomplete history is detected . For example , when the oplog to a write was <nl> - / / truncated because it was too old . <nl> - bool _hasIncompleteHistory { false } ; <nl> + / / Set to true if incomplete history is detected . For example , when the oplog to a write was <nl> + / / truncated because it was too old . <nl> + bool hasIncompleteHistory { false } ; <nl> <nl> - / / For the active txn , tracks which statement ids have been committed and at which oplog <nl> - / / opTime . Used for fast retryability check and retrieving the previous write ' s data without <nl> - / / having to scan through the oplog . <nl> - CommittedStatementTimestampMap _activeTxnCommittedStatements ; <nl> + / / For the active txn , tracks which statement ids have been committed and at which oplog <nl> + / / opTime . Used for fast retryability check and retrieving the previous write ' s data without <nl> + / / having to scan through the oplog . <nl> + CommittedStatementTimestampMap activeTxnCommittedStatements ; <nl> + } _p ; <nl> } ; <nl> <nl> } / / namespace mongo <nl> mmm a / src / mongo / db / transaction_participant_retryable_writes_test . cpp <nl> ppp b / src / mongo / db / transaction_participant_retryable_writes_test . cpp <nl> class TransactionParticipantRetryableWritesTest : public MockReplCoordServerFixt <nl> repl : : OpTime prevOpTime , <nl> boost : : optional < DurableTxnStateEnum > txnState ) { <nl> const auto session = OperationContextSession : : get ( opCtx ( ) ) ; <nl> - const auto txnParticipant = TransactionParticipant : : get ( session ) ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> const auto uuid = UUID : : gen ( ) ; <nl> <nl> class TransactionParticipantRetryableWritesTest : public MockReplCoordServerFixt <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> const auto opTime = <nl> logOp ( opCtx ( ) , kNss , uuid , session - > getSessionId ( ) , txnNum , stmtId , prevOpTime ) ; <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { stmtId } , opTime , Date_t : : now ( ) , txnState ) ; <nl> wuow . commit ( ) ; <nl> <nl> class TransactionParticipantRetryableWritesTest : public MockReplCoordServerFixt <nl> ASSERT_EQ ( txnState ! = boost : : none , <nl> txnRecordObj . hasField ( SessionTxnRecord : : kStateFieldName ) ) ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( session ) ; <nl> - ASSERT_EQ ( opTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( opTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> - ASSERT_EQ ( opTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( opTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> } <nl> <nl> private : <nl> class TransactionParticipantRetryableWritesTest : public MockReplCoordServerFixt <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionEntryNotWrittenOnBegin ) { <nl> const auto & sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const TxnNumber txnNum = 20 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> - ASSERT ( txnParticipant - > getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> + ASSERT ( txnParticipant . getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> <nl> DBDirectClient client ( opCtx ( ) ) ; <nl> auto cursor = client . query ( NamespaceString : : kSessionTransactionsTableNamespace , <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionEntryNotWrittenOnBegin ) <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionEntryWrittenAtFirstWrite ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const auto & sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> const TxnNumber txnNum = 21 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> const auto opTime = writeTxnRecord ( txnNum , 0 , { } , boost : : none ) ; <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionEntryWrittenAtFirstWrit <nl> ASSERT_EQ ( txnNum , txnRecord . getTxnNum ( ) ) ; <nl> ASSERT_EQ ( opTime , txnRecord . getLastWriteOpTime ( ) ) ; <nl> ASSERT ( ! txnRecord . getState ( ) ) ; <nl> - ASSERT_EQ ( opTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + ASSERT_EQ ( opTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , <nl> StartingNewerTransactionUpdatesThePersistedSession ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const auto & sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , <nl> ASSERT_EQ ( 200 , txnRecord . getTxnNum ( ) ) ; <nl> ASSERT_EQ ( secondOpTime , txnRecord . getLastWriteOpTime ( ) ) ; <nl> ASSERT ( ! txnRecord . getState ( ) ) ; <nl> - ASSERT_EQ ( secondOpTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + ASSERT_EQ ( secondOpTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> - ASSERT_EQ ( secondOpTime , txnParticipant - > getLastWriteOpTime ( ) ) ; <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( secondOpTime , txnParticipant . getLastWriteOpTime ( ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , TransactionTableUpdatesReplaceEntireDocument ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const auto firstOpTime = writeTxnRecord ( 100 , 0 , { } , boost : : none ) ; <nl> assertTxnRecord ( 100 , 0 , firstOpTime , boost : : none ) ; <nl> TEST_F ( TransactionParticipantRetryableWritesTest , TransactionTableUpdatesReplace <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , StartingOldTxnShouldAssert ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const TxnNumber txnNum = 20 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > beginOrContinue ( txnNum - 1 , boost : : none , boost : : none ) , <nl> - AssertionException , <nl> - ErrorCodes : : TransactionTooOld ) ; <nl> - ASSERT ( txnParticipant - > getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> + ASSERT_THROWS_CODE ( <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum - 1 , boost : : none , boost : : none ) , <nl> + AssertionException , <nl> + ErrorCodes : : TransactionTooOld ) ; <nl> + ASSERT ( txnParticipant . getLastWriteOpTime ( ) . isNull ( ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionTransactionsCollectionNotDefaultCreated ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const auto & sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , SessionTransactionsCollectionN <nl> ASSERT ( client . runCommand ( nss . db ( ) . toString ( ) , BSON ( " drop " < < nss . coll ( ) ) , dropResult ) ) ; <nl> <nl> const TxnNumber txnNum = 21 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> AutoGetCollection autoColl ( opCtx ( ) , kNss , MODE_IX ) ; <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> <nl> const auto uuid = UUID : : gen ( ) ; <nl> const auto opTime = logOp ( opCtx ( ) , kNss , uuid , sessionId , txnNum , 0 ) ; <nl> - ASSERT_THROWS ( txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + ASSERT_THROWS ( txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { 0 } , opTime , Date_t : : now ( ) , boost : : none ) , <nl> AssertionException ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , CheckStatementExecuted ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const TxnNumber txnNum = 100 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> - ASSERT ( ! txnParticipant - > checkStatementExecuted ( 1000 ) ) ; <nl> - ASSERT ( ! txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> + ASSERT ( ! txnParticipant . checkStatementExecuted ( opCtx ( ) , 1000 ) ) ; <nl> + ASSERT ( ! txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> const auto firstOpTime = writeTxnRecord ( txnNum , 1000 , { } , boost : : none ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 1000 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 1000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> <nl> - ASSERT ( ! txnParticipant - > checkStatementExecuted ( 2000 ) ) ; <nl> - ASSERT ( ! txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> + ASSERT ( ! txnParticipant . checkStatementExecuted ( opCtx ( ) , 2000 ) ) ; <nl> + ASSERT ( ! txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> writeTxnRecord ( txnNum , 2000 , firstOpTime , boost : : none ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 2000 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 2000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> <nl> / / Invalidate the session and ensure the statements still check out <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 1000 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 2000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 1000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 2000 ) ) ; <nl> <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 1000 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 2000 ) ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TransactionParticipantRetryableWritesTest , <nl> CheckStatementExecutedForInvalidatedTransactionInvariants , <nl> - " Invariant failure _isValid " ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > checkStatementExecuted ( 0 ) ; <nl> + " Invariant failure p ( ) . isValid " ) { <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . checkStatementExecuted ( opCtx ( ) , 0 ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TransactionParticipantRetryableWritesTest , <nl> WriteOpCompletedOnPrimaryForOldTransactionInvariants , <nl> - " Invariant failure txnNumber = = _activeTxnNumber " ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + " Invariant failure txnNumber = = o ( ) . activeTxnNumber " ) { <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const auto & sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> const TxnNumber txnNum = 100 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> const auto uuid = UUID : : gen ( ) ; <nl> <nl> DEATH_TEST_F ( TransactionParticipantRetryableWritesTest , <nl> AutoGetCollection autoColl ( opCtx ( ) , kNss , MODE_IX ) ; <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> const auto opTime = logOp ( opCtx ( ) , kNss , uuid , sessionId , txnNum , 0 ) ; <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { 0 } , opTime , Date_t : : now ( ) , boost : : none ) ; <nl> wuow . commit ( ) ; <nl> } <nl> DEATH_TEST_F ( TransactionParticipantRetryableWritesTest , <nl> AutoGetCollection autoColl ( opCtx ( ) , kNss , MODE_IX ) ; <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> const auto opTime = logOp ( opCtx ( ) , kNss , uuid , sessionId , txnNum - 1 , 0 ) ; <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum - 1 , { 0 } , opTime , Date_t : : now ( ) , boost : : none ) ; <nl> } <nl> } <nl> <nl> DEATH_TEST_F ( TransactionParticipantRetryableWritesTest , <nl> WriteOpCompletedOnPrimaryForInvalidatedTransactionInvariants , <nl> - " Invariant failure txnNumber = = _activeTxnNumber " ) { <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + " Invariant failure txnNumber = = o ( ) . activeTxnNumber " ) { <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> const TxnNumber txnNum = 100 ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> AutoGetCollection autoColl ( opCtx ( ) , kNss , MODE_IX ) ; <nl> WriteUnitOfWork wuow ( opCtx ( ) ) ; <nl> const auto uuid = UUID : : gen ( ) ; <nl> const auto opTime = logOp ( opCtx ( ) , kNss , uuid , * opCtx ( ) - > getLogicalSessionId ( ) , txnNum , 0 ) ; <nl> <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { 0 } , opTime , Date_t : : now ( ) , boost : : none ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , IncompleteHistoryDueToOpLogTru <nl> } ( ) ) ; <nl> } <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > checkStatementExecuted ( 0 ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 0 ) , <nl> AssertionException , <nl> ErrorCodes : : IncompleteTransactionHistory ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 1 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecuted ( 2 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 1 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 2 ) ) ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 0 ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 0 ) , <nl> AssertionException , <nl> ErrorCodes : : IncompleteTransactionHistory ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 1 ) ) ; <nl> - ASSERT ( txnParticipant - > checkStatementExecutedNoOplogEntryFetch ( 2 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 1 ) ) ; <nl> + ASSERT ( txnParticipant . checkStatementExecutedNoOplogEntryFetch ( 2 ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , ErrorOnlyWhenStmtIdBeingCheckedIsNotInCache ) { <nl> TEST_F ( TransactionParticipantRetryableWritesTest , ErrorOnlyWhenStmtIdBeingChecke <nl> const auto sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> const TxnNumber txnNum = 2 ; <nl> <nl> - const auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> - txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) ; <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) ; <nl> <nl> OperationSessionInfo osi ; <nl> osi . setSessionId ( sessionId ) ; <nl> TEST_F ( TransactionParticipantRetryableWritesTest , ErrorOnlyWhenStmtIdBeingChecke <nl> { } , <nl> false / * prepare * / , <nl> OplogSlot ( ) ) ; <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { 1 } , opTime , wallClockTime , boost : : none ) ; <nl> wuow . commit ( ) ; <nl> <nl> TEST_F ( TransactionParticipantRetryableWritesTest , ErrorOnlyWhenStmtIdBeingChecke <nl> false / * prepare * / , <nl> OplogSlot ( ) ) ; <nl> <nl> - txnParticipant - > onWriteOpCompletedOnPrimary ( <nl> + txnParticipant . onWriteOpCompletedOnPrimary ( <nl> opCtx ( ) , txnNum , { kIncompleteHistoryStmtId } , opTime , wallClockTime , boost : : none ) ; <nl> wuow . commit ( ) ; <nl> } <nl> <nl> { <nl> - auto oplog = txnParticipant - > checkStatementExecuted ( 1 ) ; <nl> + auto oplog = txnParticipant . checkStatementExecuted ( opCtx ( ) , 1 ) ; <nl> ASSERT_TRUE ( oplog ) ; <nl> ASSERT_EQ ( firstOpTime , oplog - > getOpTime ( ) ) ; <nl> } <nl> <nl> - ASSERT_THROWS ( txnParticipant - > checkStatementExecuted ( 2 ) , AssertionException ) ; <nl> + ASSERT_THROWS ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 2 ) , AssertionException ) ; <nl> <nl> / / Should have the same behavior after loading state from storage . <nl> - txnParticipant - > invalidate ( ) ; <nl> - txnParticipant - > refreshFromStorageIfNeeded ( ) ; <nl> + txnParticipant . invalidate ( opCtx ( ) ) ; <nl> + txnParticipant . refreshFromStorageIfNeeded ( opCtx ( ) ) ; <nl> <nl> { <nl> - auto oplog = txnParticipant - > checkStatementExecuted ( 1 ) ; <nl> + auto oplog = txnParticipant . checkStatementExecuted ( opCtx ( ) , 1 ) ; <nl> ASSERT_TRUE ( oplog ) ; <nl> ASSERT_EQ ( firstOpTime , oplog - > getOpTime ( ) ) ; <nl> } <nl> <nl> - ASSERT_THROWS ( txnParticipant - > checkStatementExecuted ( 2 ) , AssertionException ) ; <nl> + ASSERT_THROWS ( txnParticipant . checkStatementExecuted ( opCtx ( ) , 2 ) , AssertionException ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / src / mongo / db / transaction_participant_test . cpp <nl> ppp b / src / mongo / db / transaction_participant_test . cpp <nl> class TxnParticipantTest : public MockReplCoordServerFixture { <nl> } <nl> <nl> void runFunctionFromDifferentOpCtx ( std : : function < void ( OperationContext * ) > func ) { <nl> - / / Stash the original client . <nl> - auto originalClient = Client : : releaseCurrent ( ) ; <nl> - <nl> / / Create a new client ( e . g . for migration ) and opCtx . <nl> - auto service = opCtx ( ) - > getServiceContext ( ) ; <nl> - auto newClientOwned = service - > makeClient ( " newClient " ) ; <nl> - auto newClient = newClientOwned . get ( ) ; <nl> - Client : : setCurrent ( std : : move ( newClientOwned ) ) ; <nl> - auto newOpCtx = newClient - > makeOperationContext ( ) ; <nl> - <nl> - ON_BLOCK_EXIT ( [ & ] { <nl> - / / Restore the original client . <nl> - newOpCtx . reset ( ) ; <nl> - Client : : releaseCurrent ( ) ; <nl> - Client : : setCurrent ( std : : move ( originalClient ) ) ; <nl> - } ) ; <nl> - <nl> - / / Run the function on bahalf of another operation context . <nl> + auto newClientOwned = getServiceContext ( ) - > makeClient ( " newClient " ) ; <nl> + AlternativeClientRegion acr ( newClientOwned ) ; <nl> + auto newOpCtx = cc ( ) . makeOperationContext ( ) ; <nl> func ( newOpCtx . get ( ) ) ; <nl> } <nl> <nl> class TxnParticipantTest : public MockReplCoordServerFixture { <nl> opCtx ( ) - > lockState ( ) - > setShouldConflictWithSecondaryBatchApplication ( false ) ; <nl> auto opCtxSession = std : : make_unique < MongoDOperationContextSession > ( opCtx ( ) ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , startNewTxn ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , startNewTxn ) ; <nl> return opCtxSession ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , TransactionThrowsLockTimeoutIfLockIsUnavailable ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> { Lock : : DBLock dbXLock ( opCtx ( ) , dbName , MODE_X ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> auto clientWithDatabaseXLock = Client : : releaseCurrent ( ) ; <nl> <nl> <nl> TEST_F ( TxnParticipantTest , TransactionThrowsLockTimeoutIfLockIsUnavailable ) { <nl> <nl> MongoDOperationContextSession newOpCtxSession ( newOpCtx . get ( ) ) ; <nl> auto newTxnParticipant = TransactionParticipant : : get ( newOpCtx . get ( ) ) ; <nl> - newTxnParticipant - > beginOrContinue ( newTxnNum , false , true ) ; <nl> - newTxnParticipant - > unstashTransactionResources ( newOpCtx . get ( ) , " insert " ) ; <nl> + newTxnParticipant . beginOrContinue ( newOpCtx . get ( ) , newTxnNum , false , true ) ; <nl> + newTxnParticipant . unstashTransactionResources ( newOpCtx . get ( ) , " insert " ) ; <nl> <nl> Date_t t1 = Date_t : : now ( ) ; <nl> ASSERT_THROWS_CODE ( Lock : : DBLock ( newOpCtx . get ( ) , dbName , MODE_X ) , <nl> TEST_F ( TxnParticipantTest , StashAndUnstashResources ) { <nl> <nl> / / Perform initial unstash which sets up a WriteUnitOfWork . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> ASSERT_EQUALS ( originalLocker , opCtx ( ) - > lockState ( ) ) ; <nl> ASSERT_EQUALS ( originalRecoveryUnit , opCtx ( ) - > recoveryUnit ( ) ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> ASSERT ( opCtx ( ) - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> / / Stash resources . The original Locker and RecoveryUnit now belong to the stash . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_NOT_EQUALS ( originalLocker , opCtx ( ) - > lockState ( ) ) ; <nl> ASSERT_NOT_EQUALS ( originalRecoveryUnit , opCtx ( ) - > recoveryUnit ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> TEST_F ( TxnParticipantTest , StashAndUnstashResources ) { <nl> <nl> / / Unstash the stashed resources . This restores the original Locker and RecoveryUnit to the <nl> / / OperationContext . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> ASSERT_EQUALS ( originalLocker , opCtx ( ) - > lockState ( ) ) ; <nl> ASSERT_EQUALS ( originalRecoveryUnit , opCtx ( ) - > recoveryUnit ( ) ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> <nl> / / Commit the transaction . This allows us to release locks . <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CannotSpecifyStartTransactionOnInProgressTxn ) { <nl> / / Must specify startTransaction = true and autocommit = false to start a transaction . <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> / / Cannot try to start a transaction that already started . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , true ) , <nl> - AssertionException , <nl> - ErrorCodes : : ConflictingOperationInProgress ) ; <nl> + ASSERT_THROWS_CODE ( <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , true ) , <nl> + AssertionException , <nl> + ErrorCodes : : ConflictingOperationInProgress ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , AutocommitRequiredOnEveryTxnOp ) { <nl> TEST_F ( TxnParticipantTest , AutocommitRequiredOnEveryTxnOp ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / We must have stashed transaction resources to do a second operation on the transaction . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> auto txnNum = * opCtx ( ) - > getTxnNumber ( ) ; <nl> / / Omitting ' autocommit ' after the first statement of a transaction should throw an error . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > beginOrContinue ( txnNum , boost : : none , boost : : none ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( opCtx ( ) , txnNum , boost : : none , boost : : none ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> <nl> / / Including autocommit = false should succeed . <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TxnParticipantTest , AutocommitCannotBeTrue , " invariant " ) { <nl> DEATH_TEST_F ( TxnParticipantTest , AutocommitCannotBeTrue , " invariant " ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Passing ' autocommit = true ' is not allowed and should crash . <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , true , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , true , boost : : none ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TxnParticipantTest , StartTransactionCannotBeFalse , " invariant " ) { <nl> DEATH_TEST_F ( TxnParticipantTest , StartTransactionCannotBeFalse , " invariant " ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Passing ' startTransaction = false ' is not allowed and should crash . <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , false ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , false ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , SameTransactionPreservesStoredStatements ) { <nl> TEST_F ( TxnParticipantTest , SameTransactionPreservesStoredStatements ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / We must have stashed transaction resources to re - open the transaction . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> ASSERT_BSONOBJ_EQ ( operation . toBSON ( ) , <nl> - txnParticipant - > getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> + txnParticipant . getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Check the transaction operations before re - opening the transaction . <nl> ASSERT_BSONOBJ_EQ ( operation . toBSON ( ) , <nl> - txnParticipant - > getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> + txnParticipant . getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> <nl> / / Re - opening the same transaction should have no effect . <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) ; <nl> ASSERT_BSONOBJ_EQ ( operation . toBSON ( ) , <nl> - txnParticipant - > getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> + txnParticipant . getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , AbortClearsStoredStatements ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> ASSERT_BSONOBJ_EQ ( operation . toBSON ( ) , <nl> - txnParticipant - > getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> + txnParticipant . getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_TRUE ( txnParticipant - > getTransactionOperationsForTest ( ) . empty ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . getTransactionOperationsForTest ( ) . empty ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> / / This test makes sure the commit machinery works even when no operations are done on the <nl> TEST_F ( TxnParticipantTest , AbortClearsStoredStatements ) { <nl> TEST_F ( TxnParticipantTest , EmptyTransactionCommit ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> } <nl> <nl> / / This test makes sure the commit machinery works even when no operations are done on the <nl> TEST_F ( TxnParticipantTest , EmptyTransactionCommit ) { <nl> TEST_F ( TxnParticipantTest , EmptyPreparedTransactionCommit ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , PrepareSucceedsWithNestedLocks ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> { <nl> Lock : : GlobalLock lk1 ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> Lock : : GlobalLock lk2 ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> } <nl> <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CommitTransactionSetsCommitTimestampOnPreparedTransaction ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> auto originalFn = _opObserver - > onTransactionCommitFn ; <nl> TEST_F ( TxnParticipantTest , CommitTransactionSetsCommitTimestampOnPreparedTransac <nl> ASSERT ( statements . empty ( ) ) ; <nl> } ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> <nl> / / The recovery unit is reset on commit . <nl> ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CommitTransactionWithCommitTimestampFailsOnUnprepared <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , CommitTransactionDoesNotSetCommitTimestampOnUnprepare <nl> } ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CommitTransactionWithoutCommitTimestampFailsOnPrepare <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) , <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , CommitTransactionWithNullCommitTimestampFailsOnPrepar <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( opCtx ( ) , Timestamp ( ) , { } ) , <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( opCtx ( ) , Timestamp ( ) , { } ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( <nl> opCtx ( ) , Timestamp ( prepareTimestamp . getSecs ( ) - 1 , 1 ) , { } ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> TEST_F ( TxnParticipantTest , <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( opCtx ( ) , prepareTimestamp , { } ) , <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( opCtx ( ) , prepareTimestamp , { } ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , <nl> TEST_F ( TxnParticipantTest , EmptyTransactionAbort ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> / / This test makes sure the abort machinery works even when no operations are done on the <nl> TEST_F ( TxnParticipantTest , EmptyTransactionAbort ) { <nl> TEST_F ( TxnParticipantTest , EmptyPreparedTransactionAbort ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfUnstashAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / An unstash after an abort should uassert . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfStashAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant - > <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / A stash after an abort should be a noop . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfAddTransactionOperationAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / An addTransactionOperation ( ) after an abort should uassert . <nl> - auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfRetrieveCompletedTransactionOperationsAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / A retrieveCompletedTransactionOperations ( ) after an abort should uassert . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > retrieveCompletedTransactionOperations ( opCtx ( ) ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfClearOperationsInMemory ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / An clearOperationsInMemory ( ) after an abort should uassert . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > clearOperationsInMemory ( opCtx ( ) ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfCommitUnpreparedTransactionAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / A commitUnpreparedTransaction ( ) after an abort should uassert . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfCommitPreparedTransactionAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - auto prepareTS = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - auto commitTS = Timestamp ( prepareTS . getSecs ( ) , prepareTS . getInc ( ) + 1 ) ; <nl> - <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / A commitPreparedTransaction ( ) after an abort should succeed since the abort should fail . <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> - <nl> - ASSERT ( _opObserver - > transactionCommitted ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfActiveUnpreparedAbortAndArbitraryAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / The operation throws for some reason and aborts implicitly . <nl> - / / Abort active transaction after it ' s been aborted by KillSession is a no - op . <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) = = nullptr ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfActivePreparedAbortAndArbitraryAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - <nl> - / / The operation throws for some reason and aborts implicitly . <nl> - / / Abort active transaction after it ' s been aborted by KillSession is a no - op . <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) = = nullptr ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ConcurrencyOfPrepareTransactionAndAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - <nl> - / / A prepareTransaction ( ) after an abort should uassert . <nl> - ASSERT_THROWS_CODE ( txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> - ASSERT_FALSE ( _opObserver - > transactionPrepared ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , KillSessionsDuringPrepareDoesNotAbortTransaction ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> auto ruPrepareTimestamp = Timestamp ( ) ; <nl> auto originalFn = _opObserver - > onTransactionPrepareFn ; <nl> TEST_F ( TxnParticipantTest , KillSessionsDuringPrepareDoesNotAbortTransaction ) { <nl> ASSERT_FALSE ( ruPrepareTimestamp . isNull ( ) ) ; <nl> <nl> / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } ; <nl> <nl> / / Check that prepareTimestamp gets set . <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> ASSERT_EQ ( ruPrepareTimestamp , prepareTimestamp ) ; <nl> / / Check that the oldest prepareTimestamp is the one we just set . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> ASSERT ( _opObserver - > transactionPrepared ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> - DEATH_TEST_F ( TxnParticipantTest , AbortDuringPrepareIsFatal , " Invariant " ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - <nl> - auto originalFn = _opObserver - > onTransactionPrepareFn ; <nl> - _opObserver - > onTransactionPrepareFn = [ & ] ( ) { <nl> - originalFn ( ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , ThrowDuringOnTransactionPrepareAbortsTransaction ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> _opObserver - > onTransactionPrepareThrowsException = true ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . prepareTransaction ( opCtx ( ) , { } ) , <nl> AssertionException , <nl> ErrorCodes : : OperationFailed ) ; <nl> ASSERT_FALSE ( _opObserver - > transactionPrepared ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , KillSessionsDuringPreparedCommitDoesNotAbortTransaction ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> - <nl> - auto originalFn = _opObserver - > onTransactionCommitFn ; <nl> - _opObserver - > onTransactionCommitFn = [ & ] ( boost : : optional < OplogSlot > commitOplogEntryOpTime , <nl> - boost : : optional < Timestamp > commitTimestamp , <nl> - std : : vector < repl : : ReplOperation > & statements ) { <nl> - originalFn ( commitOplogEntryOpTime , commitTimestamp , statements ) ; <nl> - ASSERT ( commitOplogEntryOpTime ) ; <nl> - ASSERT ( commitTimestamp ) ; <nl> - <nl> - ASSERT_GT ( * commitTimestamp , prepareTimestamp ) ; <nl> - <nl> - ASSERT ( statements . empty ( ) ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> - <nl> - / / The recovery unit is reset on commit . <nl> - ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> - <nl> - ASSERT ( _opObserver - > transactionCommitted ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , StepDownAfterPrepareDoesNotBlock ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> / / Test that we can acquire the RSTL in mode X , and then immediately release it so the test can <nl> / / complete successfully . <nl> TEST_F ( TxnParticipantTest , StepDownAfterPrepareDoesNotBlock ) { <nl> } ; <nl> runFunctionFromDifferentOpCtx ( func ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> ASSERT ( _opObserver - > transactionAborted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , StepDownAfterPrepareDoesNotBlockThenCommit ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> / / Test that we can acquire the RSTL in mode X , and then immediately release it so the test can <nl> TEST_F ( TxnParticipantTest , StepDownAfterPrepareDoesNotBlockThenCommit ) { <nl> } ; <nl> runFunctionFromDifferentOpCtx ( func ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> ASSERT ( _opObserver - > transactionCommitted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , StepDownDuringAbortSucceeds ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> ASSERT_OK ( repl : : ReplicationCoordinator : : get ( opCtx ( ) ) - > setFollowerMode ( <nl> repl : : MemberState : : RS_SECONDARY ) ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> ASSERT ( _opObserver - > transactionAborted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , StepDownDuringPreparedAbortFails ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> ASSERT_OK ( repl : : ReplicationCoordinator : : get ( opCtx ( ) ) - > setFollowerMode ( <nl> repl : : MemberState : : RS_SECONDARY ) ) ; <nl> ASSERT_THROWS_CODE ( <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) , AssertionException , ErrorCodes : : NotMaster ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) , AssertionException , ErrorCodes : : NotMaster ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , StepDownDuringPreparedCommitFails ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> ASSERT_OK ( repl : : ReplicationCoordinator : : get ( opCtx ( ) ) - > setFollowerMode ( <nl> repl : : MemberState : : RS_SECONDARY ) ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) , <nl> AssertionException , <nl> ErrorCodes : : NotMaster ) ; <nl> } <nl> <nl> - TEST_F ( TxnParticipantTest , ArbitraryAbortDuringPreparedCommitDoesNotAbortTransaction ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> - <nl> - auto originalFn = _opObserver - > onTransactionCommitFn ; <nl> - _opObserver - > onTransactionCommitFn = [ & ] ( boost : : optional < OplogSlot > commitOplogEntryOpTime , <nl> - boost : : optional < Timestamp > commitTimestamp , <nl> - std : : vector < repl : : ReplOperation > & statements ) { <nl> - originalFn ( commitOplogEntryOpTime , commitTimestamp , statements ) ; <nl> - ASSERT ( commitOplogEntryOpTime ) ; <nl> - ASSERT ( commitTimestamp ) ; <nl> - <nl> - ASSERT_GT ( * commitTimestamp , prepareTimestamp ) ; <nl> - <nl> - ASSERT ( statements . empty ( ) ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - auto func = [ & ] ( OperationContext * opCtx ) { txnParticipant - > abortArbitraryTransaction ( ) ; } ; <nl> - runFunctionFromDifferentOpCtx ( func ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> - <nl> - / / The recovery unit is reset on commit . <nl> - ASSERT ( opCtx ( ) - > recoveryUnit ( ) - > getCommitTimestamp ( ) . isNull ( ) ) ; <nl> - <nl> - ASSERT ( _opObserver - > transactionCommitted ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> - } <nl> - <nl> DEATH_TEST_F ( TxnParticipantTest , <nl> ThrowDuringPreparedOnTransactionCommitIsFatal , <nl> " Caught exception during commit " ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> _opObserver - > onTransactionCommitThrowsException = true ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , ThrowDuringUnpreparedCommitLetsTheAbortAtEntryPointToCleanUp ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> _opObserver - > onTransactionCommitThrowsException = true ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) , <nl> AssertionException , <nl> ErrorCodes : : OperationFailed ) ; <nl> ASSERT_FALSE ( _opObserver - > transactionCommitted ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> <nl> / / Simulate the abort at entry point . <nl> - txnParticipant - > abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , ContinuingATransactionWithNoResourcesAborts ) { <nl> TEST_F ( TxnParticipantTest , ContinuingATransactionWithNoResourcesAborts ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) , <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) , <nl> AssertionException , <nl> ErrorCodes : : NoSuchTransaction ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , KillSessionsDoesNotAbortPreparedTransactions ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> auto ruPrepareTimestamp = Timestamp ( ) ; <nl> auto originalFn = _opObserver - > onTransactionPrepareFn ; <nl> TEST_F ( TxnParticipantTest , KillSessionsDoesNotAbortPreparedTransactions ) { <nl> } ; <nl> <nl> / / Check that prepareTimestamp gets set . <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> ASSERT_EQ ( ruPrepareTimestamp , prepareTimestamp ) ; <nl> / / Check that the oldest prepareTimestamp is the one we just set . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT ( _opObserver - > transactionPrepared ) ; <nl> } <nl> <nl> - TEST_F ( TxnParticipantTest , TransactionTimeoutDoesNotAbortPreparedTransactions ) { <nl> + TEST_F ( TxnParticipantTest , CannotAbortArbitraryPreparedTransactions ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> auto ruPrepareTimestamp = Timestamp ( ) ; <nl> auto originalFn = _opObserver - > onTransactionPrepareFn ; <nl> TEST_F ( TxnParticipantTest , TransactionTimeoutDoesNotAbortPreparedTransactions ) { <nl> } ; <nl> <nl> / / Check that prepareTimestamp gets set . <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> ASSERT_EQ ( ruPrepareTimestamp , prepareTimestamp ) ; <nl> / / Check that the oldest prepareTimestamp is the one we just set . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - ASSERT ( ! txnParticipant - > expired ( ) ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT ( ! txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT ( ! txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT ( _opObserver - > transactionPrepared ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CannotStartNewTransactionWhilePreparedTransactionInPr <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> auto ruPrepareTimestamp = Timestamp ( ) ; <nl> auto originalFn = _opObserver - > onTransactionPrepareFn ; <nl> TEST_F ( TxnParticipantTest , CannotStartNewTransactionWhilePreparedTransactionInPr <nl> } ; <nl> <nl> / / Check that prepareTimestamp gets set . <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> ASSERT_EQ ( ruPrepareTimestamp , prepareTimestamp ) ; <nl> <nl> / / Check that the oldest prepareTimestamp is the one we just set . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> OperationContextSession : : checkIn ( opCtx ( ) ) ; <nl> { <nl> + auto guard = makeGuard ( [ & ] ( ) { OperationContextSession : : checkOut ( opCtx ( ) ) ; } ) ; <nl> / / Try to start a new transaction while there is already a prepared transaction on the <nl> / / session . This should fail with a PreparedTransactionInProgress error . <nl> - auto func = [ <nl> + runFunctionFromDifferentOpCtx ( [ <nl> lsid = * opCtx ( ) - > getLogicalSessionId ( ) , <nl> txnNumberToStart = * opCtx ( ) - > getTxnNumber ( ) + 1 <nl> ] ( OperationContext * newOpCtx ) { <nl> newOpCtx - > setLogicalSessionId ( lsid ) ; <nl> newOpCtx - > setTxnNumber ( txnNumberToStart ) ; <nl> + <nl> MongoDOperationContextSession ocs ( newOpCtx ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( newOpCtx ) ; <nl> - <nl> - ASSERT_THROWS_CODE ( txnParticipant - > beginOrContinue ( txnNumberToStart , false , true ) , <nl> - AssertionException , <nl> - ErrorCodes : : PreparedTransactionInProgress ) ; <nl> - } ; <nl> - <nl> - runFunctionFromDifferentOpCtx ( func ) ; <nl> + ASSERT_THROWS_CODE ( <nl> + txnParticipant . beginOrContinue ( newOpCtx , txnNumberToStart , false , true ) , <nl> + AssertionException , <nl> + ErrorCodes : : PreparedTransactionInProgress ) ; <nl> + } ) ; <nl> } <nl> - OperationContextSession : : checkOut ( opCtx ( ) ) ; <nl> <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT ( _opObserver - > transactionPrepared ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , CannotInsertInPreparedTransaction ) { <nl> auto outerScopedSession = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) , <nl> AssertionException , <nl> ErrorCodes : : PreparedTransactionInProgress ) ; <nl> <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT ( _opObserver - > transactionPrepared ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , ImplictAbortDoesNotAbortPreparedTransaction ) { <nl> auto outerScopedSession = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> / / The next command throws an exception and wants to abort the transaction . <nl> / / This is a no - op . <nl> - txnParticipant - > abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ( ) ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveUnpreparedOrStashPreparedTransaction ( opCtx ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_TRUE ( _opObserver - > transactionPrepared ) ; <nl> } <nl> <nl> - DEATH_TEST_F ( TxnParticipantTest , AbortIsIllegalDuringCommittingPreparedTransaction , " invariant " ) { <nl> + DEATH_TEST_F ( TxnParticipantTest , <nl> + AbortIsIllegalDuringCommittingPreparedTransaction , <nl> + " isCommittingWithPrepare " ) { <nl> auto outerScopedSession = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> auto commitTS = Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> / / Check that the oldest prepareTimestamp is the one we just set . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> <nl> - auto sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> - auto txnNum = * opCtx ( ) - > getTxnNumber ( ) ; <nl> _opObserver - > onTransactionCommitFn = [ & ] ( boost : : optional < OplogSlot > commitOplogEntryOpTime , <nl> boost : : optional < Timestamp > commitTimestamp , <nl> std : : vector < repl : : ReplOperation > & statements ) { <nl> - / / This should never happen . <nl> - auto func = [ & ] ( OperationContext * opCtx ) { <nl> - opCtx - > setLogicalSessionId ( sessionId ) ; <nl> - opCtx - > setTxnNumber ( txnNum ) ; <nl> - / / Hit an invariant . This should never happen . <nl> - txnParticipant - > abortActiveTransaction ( opCtx ) ; <nl> - } ; <nl> - runFunctionFromDifferentOpCtx ( func ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + / / Hit an invariant . This should never happen . <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTS , { } ) ; <nl> / / Check that we removed the prepareTimestamp from the set . <nl> ASSERT_FALSE ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , CannotContinueNonExistentTransaction ) { <nl> MongoDOperationContextSession opCtxSession ( opCtx ( ) ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) , <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , false , boost : : none ) , <nl> AssertionException , <nl> ErrorCodes : : NoSuchTransaction ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , TransactionTooLargeWhileBuilding ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> / / Two 6MB operations should succeed ; three 6MB operations should fail . <nl> constexpr size_t kBigDataSize = 6 * 1024 * 1024 ; <nl> TEST_F ( TxnParticipantTest , TransactionTooLargeWhileBuilding ) { <nl> kNss , <nl> kUUID , <nl> BSON ( " _id " < < 0 < < " data " < < BSONBinData ( bigData . get ( ) , kBigDataSize , BinDataGeneral ) ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) , <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) , <nl> AssertionException , <nl> ErrorCodes : : TransactionTooLarge ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , StashInNestedSessionIsANoop ) { <nl> <nl> / / Perform initial unstash , which sets up a WriteUnitOfWork . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> ASSERT_EQUALS ( originalLocker , opCtx ( ) - > lockState ( ) ) ; <nl> ASSERT_EQUALS ( originalRecoveryUnit , opCtx ( ) - > recoveryUnit ( ) ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> TEST_F ( TxnParticipantTest , StashInNestedSessionIsANoop ) { <nl> { <nl> / / Make it look like we ' re in a DBDirectClient running a nested operation . <nl> DirectClientSetter inDirectClient ( opCtx ( ) ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / The stash was a noop , so the locker , RecoveryUnit , and WriteUnitOfWork on the <nl> / / OperationContext are unaffected . <nl> class ShardedClusterParticipantTest : public TxnParticipantTest { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - 50911 ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + 50911 ) ; <nl> } <nl> <nl> void canSpecifyStartTransactionOnAbortedTxn ( ) { <nl> class ShardedClusterParticipantTest : public TxnParticipantTest { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> } <nl> <nl> void cannotSpecifyStartTransactionOnCommittedTxn ( ) { <nl> class ShardedClusterParticipantTest : public TxnParticipantTest { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - 50911 ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + 50911 ) ; <nl> } <nl> <nl> void cannotSpecifyStartTransactionOnPreparedTxn ( ) { <nl> class ShardedClusterParticipantTest : public TxnParticipantTest { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - 50911 ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + 50911 ) ; <nl> } <nl> <nl> void cannotSpecifyStartTransactionOnStartedRetryableWrite ( ) { <nl> MongoDOperationContextSession opCtxSession ( opCtx ( ) ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> - ASSERT_FALSE ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> + ASSERT_FALSE ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> auto autocommit = false ; <nl> auto startTransaction = true ; <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - 50911 ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + 50911 ) ; <nl> } <nl> <nl> void cannotSpecifyStartTransactionOnAbortedPreparedTransaction ( ) { <nl> class ShardedClusterParticipantTest : public TxnParticipantTest { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> startTransaction = true ; <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - 50911 ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + 50911 ) ; <nl> } <nl> } ; <nl> <nl> TEST_F ( ConfigTxnParticipantTest , CannotSpecifyStartTransactionOnAbortedPreparedT <nl> cannotSpecifyStartTransactionOnAbortedPreparedTransaction ( ) ; <nl> } <nl> <nl> - TEST_F ( TxnParticipantTest , KillSessionsDuringUnpreparedAbortSucceeds ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - <nl> - auto originalFn = _opObserver - > onTransactionAbortFn ; <nl> - _opObserver - > onTransactionAbortFn = [ & ] { <nl> - originalFn ( ) ; <nl> - <nl> - / / The transaction may be aborted without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - <nl> - ASSERT ( _opObserver - > transactionAborted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> - TEST_F ( TxnParticipantTest , ActiveAbortIsLegalDuringUnpreparedAbort ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - <nl> - auto sessionId = * opCtx ( ) - > getLogicalSessionId ( ) ; <nl> - auto txnNumber = * opCtx ( ) - > getTxnNumber ( ) ; <nl> - auto originalFn = _opObserver - > onTransactionAbortFn ; <nl> - _opObserver - > onTransactionAbortFn = [ & ] { <nl> - originalFn ( ) ; <nl> - <nl> - auto func = [ & ] ( OperationContext * opCtx ) { <nl> - opCtx - > setLogicalSessionId ( sessionId ) ; <nl> - opCtx - > setTxnNumber ( txnNumber ) ; <nl> - <nl> - / / Prevent recursion . <nl> - _opObserver - > onTransactionAbortFn = originalFn ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } ; <nl> - runFunctionFromDifferentOpCtx ( func ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( _opObserver - > transactionAborted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> TEST_F ( TxnParticipantTest , ThrowDuringUnpreparedOnTransactionAbort ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> _opObserver - > onTransactionAbortThrowsException = true ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > abortActiveTransaction ( opCtx ( ) ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . abortActiveTransaction ( opCtx ( ) ) , <nl> AssertionException , <nl> ErrorCodes : : OperationFailed ) ; <nl> } <nl> <nl> - TEST_F ( TxnParticipantTest , KillSessionsDuringPreparedAbortFails ) { <nl> - auto sessionCheckout = checkOutSession ( ) ; <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> - <nl> - auto originalFn = _opObserver - > onTransactionAbortFn ; <nl> - _opObserver - > onTransactionAbortFn = [ & ] { <nl> - originalFn ( ) ; <nl> - <nl> - / / KillSessions may attempt to abort without checking out the txnParticipant . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> - } ; <nl> - <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - <nl> - ASSERT ( _opObserver - > transactionAborted ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> - } <nl> - <nl> TEST_F ( TxnParticipantTest , ThrowDuringPreparedOnTransactionAbortIsFatal ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> _opObserver - > onTransactionAbortThrowsException = true ; <nl> <nl> - ASSERT_THROWS_CODE ( txnParticipant - > abortActiveTransaction ( opCtx ( ) ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . abortActiveTransaction ( opCtx ( ) ) , <nl> AssertionException , <nl> ErrorCodes : : OperationFailed ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , ReacquireLocksForPreparedTransactionsOnStepUp ) { <nl> repl : : UnreplicatedWritesBlock uwb ( opCtx ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > writesAreReplicated ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> / / Simulate the locking of an insert . <nl> { <nl> Lock : : DBLock dbLock ( opCtx ( ) , " test " , MODE_IX ) ; <nl> Lock : : CollectionLock collLock ( opCtx ( ) - > lockState ( ) , " test . foo " , MODE_IX ) ; <nl> } <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , repl : : OpTime ( { 1 , 1 } , 1 ) ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , repl : : OpTime ( { 1 , 1 } , 1 ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> / / Secondary yields locks for prepared transactions . <nl> - ASSERT_FALSE ( txnParticipant - > getTxnResourceStashLockerForTest ( ) - > isLocked ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . getTxnResourceStashLockerForTest ( ) - > isLocked ( ) ) ; <nl> } <nl> <nl> / / Step - up will restore the locks of prepared transactions . <nl> TEST_F ( TxnParticipantTest , ReacquireLocksForPreparedTransactionsOnStepUp ) { <nl> { <nl> auto sessionCheckout = checkOutSession ( { } ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > getTxnResourceStashLockerForTest ( ) - > isLocked ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . getTxnResourceStashLockerForTest ( ) - > isLocked ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> } <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , IncrementPreparedTransaction ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> unsigned long long beforePrepareCount = <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPrepared ( ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPrepared ( ) , beforePrepareCount + 1U ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , IncrementPreparedTransaction ) { <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalCommittedOnCommit ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> unsigned long long beforeCommitCount = <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalCommitted ( ) ; <nl> <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> / / Assert that the committed counter is incremented by 1 . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalCommitted ( ) , beforeCommitCount + 1U ) ; <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalCommittedOnCommit ) { <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalPreparedThenCommitted ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> unsigned long long beforePreparedThenCommittedCount = <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPreparedThenCommitted ( ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPreparedThenCommitted ( ) , <nl> beforePreparedThenCommittedCount + 1U ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalPreparedThenCommitted ) { <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalAbortedUponAbort ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> unsigned long long beforeAbortCount = <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalAborted ( ) ; <nl> <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> <nl> / / Assert that the aborted counter is incremented by 1 . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalAborted ( ) , beforeAbortCount + 1U ) ; <nl> TEST_F ( TransactionsMetricsTest , IncrementTotalPreparedThenAborted ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPreparedThenAborted ( ) , <nl> beforePreparedThenAbortedCount + 1U ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , IncrementCurrentPreparedWithCommit ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentPrepared ( ) , <nl> beforeCurrentPrepared + 1U ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> - ASSERT ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + ASSERT ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentPrepared ( ) , beforeCurrentPrepared ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , IncrementCurrentPreparedWithAbort ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentPrepared ( ) , <nl> beforeCurrentPrepared + 1U ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentPrepared ( ) , beforeCurrentPrepared ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , TrackTotalOpenTransactionsWithAbort ) { <nl> / / Tests that starting a transaction increments the open transactions counter by 1 . <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , <nl> beforeTransactionStart + 1U ) ; <nl> <nl> / / Tests that stashing the transaction resources does not affect the open transactions counter . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , <nl> beforeTransactionStart + 1U ) ; <nl> <nl> / / Tests that aborting a transaction decrements the open transactions counter by 1 . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , beforeTransactionStart ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , TrackTotalOpenTransactionsWithCommit ) { <nl> / / Tests that starting a transaction increments the open transactions counter by 1 . <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , <nl> beforeTransactionStart + 1U ) ; <nl> <nl> / / Tests that stashing the transaction resources does not affect the open transactions counter . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , <nl> beforeTransactionStart + 1U ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> / / Tests that committing a transaction decrements the open transactions counter by 1 . <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentOpen ( ) , beforeTransactionStart ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , TrackTotalActiveAndInactiveTransactionsWithCommi <nl> / / Tests that the first unstash increments the active counter and decrements the inactive <nl> / / counter . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActiveCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> TEST_F ( TransactionsMetricsTest , TrackTotalActiveAndInactiveTransactionsWithCommi <nl> / / Tests that stashing the transaction resources decrements active counter and increments <nl> / / inactive counter . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactiveCounter + 1U ) ; <nl> <nl> / / Tests that the second unstash increments the active counter and decrements the inactive <nl> / / counter . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActiveCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> <nl> / / Tests that committing a transaction decrements the active counter only . <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TrackTotalActiveAndInactiveTransactionsWithStash <nl> / / Tests that the first unstash increments the active counter and decrements the inactive <nl> / / counter . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActiveCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> TEST_F ( TransactionsMetricsTest , TrackTotalActiveAndInactiveTransactionsWithStash <nl> / / Tests that stashing the transaction resources decrements active counter and increments <nl> / / inactive counter . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactiveCounter + 1U ) ; <nl> <nl> / / Tests that aborting a stashed transaction decrements the inactive counter only . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TrackTotalActiveAndInactiveTransactionsWithUnsta <nl> / / Tests that the first unstash increments the active counter and decrements the inactive <nl> / / counter . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActiveCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> <nl> / / Tests that aborting a stashed transaction decrements the active counter only . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , beforeInactiveCounter ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TrackCurrentActiveAndInactivePreparedTransaction <nl> <nl> / / Tests that unstashing a transaction puts it into an active state . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> TEST_F ( TransactionsMetricsTest , TrackCurrentActiveAndInactivePreparedTransaction <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalPrepared ( ) , beforePrepareCount + 1U ) ; <nl> <nl> / / Tests that the first stash decrements the active counter and increments the inactive counter . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactivePreparedCounter + 1U ) ; <nl> <nl> / / Tests that unstashing increments the active counter and decrements the inactive counter . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactivePreparedCounter ) ; <nl> <nl> / / Tests that committing decrements the active counter only . <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> TEST_F ( TransactionsMetricsTest , <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Tests that unstashing a transaction increments the active counter only . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> TEST_F ( TransactionsMetricsTest , <nl> <nl> / / Tests that stashing a prepared transaction decrements the active counter and increments the <nl> / / inactive counter . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactivePreparedCounter + 1U ) ; <nl> <nl> / / Tests that aborting a stashed prepared transaction decrements the inactive counter only . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter + 1U ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> beforeInactivePreparedCounter ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , <nl> beforeActivePreparedCounter ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentInactive ( ) , <nl> TEST_F ( TransactionsMetricsTest , TransactionErrorsBeforeUnstash ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> const bool autocommit = false ; <nl> const boost : : optional < bool > startTransaction = boost : : none ; <nl> - ASSERT_THROWS_CODE ( <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> - AssertionException , <nl> - ErrorCodes : : NoSuchTransaction ) ; <nl> + ASSERT_THROWS_CODE ( txnParticipant . beginOrContinue ( <nl> + opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , autocommit , startTransaction ) , <nl> + AssertionException , <nl> + ErrorCodes : : NoSuchTransaction ) ; <nl> <nl> / / The transaction is now aborted . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getCurrentActive ( ) , beforeActiveCounter ) ; <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsDurationShouldBeSetUponCom <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> / / Advance the clock . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsPreparedDurationShouldBeSe <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsPreparedDurationShouldBeSe <nl> tickSource - > advance ( Microseconds ( 10 ) ) ; <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsDurationShouldBeSetUponAbo <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> / / Advance the clock . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsPreparedDurationShouldBeSe <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> / / Advance the clock . <nl> tickSource - > advance ( Microseconds ( 10 ) ) ; <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsDurationShouldKeepIncreasi <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction ' s duration should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Commit the transaction and check duration . <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> <nl> / / The transaction committed , so the duration shouldn ' t have increased even if more time passed . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The prepared transaction ' s duration should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Commit the prepared transaction and check the prepared duration . <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> <nl> / / The prepared transaction committed , so the prepared duration shouldn ' t have increased even if <nl> / / more time passed . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , SingleTransactionStatsDurationShouldKeepIncreasi <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction ' s duration should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Abort the transaction and check duration . <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> <nl> / / The transaction aborted , so the duration shouldn ' t have increased even if more time passed . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> - tickSource , tickSource - > getTicks ( ) ) , <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( tickSource , <nl> + tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The prepared transaction ' s duration should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Abort the prepared transaction and check the prepared duration . <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> <nl> / / The prepared transaction aborted , so the prepared duration shouldn ' t have increased even if <nl> / / more time passed . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeActiveMicrosShouldBeSetUponUnstashAndStash ) <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time active should be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Advance clock during inactive period . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased only during active period . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / Advance clock during inactive period . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased again . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 200 } ) ; <nl> <nl> / / Start a new transaction . <nl> const auto higherTxnNum = * opCtx ( ) - > getTxnNumber ( ) + 1 ; <nl> - txnParticipant - > beginOrContinue ( higherTxnNum , false , true ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , higherTxnNum , false , true ) ; <nl> <nl> / / Time active should be zero for a new transaction . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeActiveMicrosShouldBeSetUponUnstashAndAbort ) <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time active should be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> <nl> / / Time active should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction is not active after abort , so time active should not have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeActiveMicrosShouldNotBeSetUponAbortOnly ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time active should be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> <nl> / / Advance clock during inactive period . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> <nl> / / Time active should still be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeActiveMicrosShouldIncreaseUntilStash ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time active should be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 100 ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased again . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction is no longer active , so time active should have stopped increasing . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeActiveMicrosShouldIncreaseUntilCommit ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time active should be zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time active should have increased again . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 200 } ) ; <nl> <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction is no longer active , so time active should have stopped increasing . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds ( 200 ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , AdditiveMetricsObjectsShouldBeAddedTogetherUponS <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Initialize field values for both AdditiveMetrics objects . <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysExamined = 5 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> 2 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . docsExamined = 0 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 3 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 1 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 3 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . nModified = 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . ninserted = 4 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysInserted = 1 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysDeleted = <nl> - 0 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysDeleted = 0 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysDeleted = 0 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) <nl> . getOpDebug ( ) <nl> - > additiveMetrics . prepareReadConflicts = 5 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . prepareReadConflicts = 4 ; <nl> <nl> auto additiveMetricsToCompare = <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> additiveMetricsToCompare . add ( CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> - ASSERT ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> + ASSERT ( txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> additiveMetricsToCompare ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , AdditiveMetricsObjectsShouldBeAddedTogetherUponC <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Initialize field values for both AdditiveMetrics objects . <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> 3 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysExamined = 2 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> 0 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . docsExamined = 2 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 4 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 5 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 4 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 5 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . nModified = 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . ninserted = 1 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . ndeleted = 4 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . ndeleted = 4 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . ndeleted = 0 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysInserted = 1 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) <nl> . getOpDebug ( ) <nl> - > additiveMetrics . prepareReadConflicts = 0 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . prepareReadConflicts = 0 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) <nl> - . getOpDebug ( ) <nl> - - > additiveMetrics . writeConflicts = 6 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . writeConflicts = <nl> + 6 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . writeConflicts = 3 ; <nl> <nl> auto additiveMetricsToCompare = <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> additiveMetricsToCompare . add ( CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> - ASSERT ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> + ASSERT ( txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> additiveMetricsToCompare ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , AdditiveMetricsObjectsShouldBeAddedTogetherUponA <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Initialize field values for both AdditiveMetrics objects . <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysExamined = <nl> 2 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysExamined = 4 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . docsExamined = <nl> 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . docsExamined = 3 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 2 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 0 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nMatched = 2 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . nModified = 0 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . nModified = 3 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . ndeleted = 5 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysInserted = <nl> 1 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysInserted = 1 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysDeleted = <nl> - 6 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . keysDeleted = 6 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . keysDeleted = 0 ; <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) <nl> - . getOpDebug ( ) <nl> - - > additiveMetrics . writeConflicts = 3 ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . writeConflicts = <nl> + 3 ; <nl> CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics . writeConflicts = 3 ; <nl> <nl> auto additiveMetricsToCompare = <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics ; <nl> additiveMetricsToCompare . add ( CurOp : : get ( opCtx ( ) ) - > debug ( ) . additiveMetrics ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> <nl> - ASSERT ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> + ASSERT ( txnParticipant . getSingleTransactionStatsForTest ( ) . getOpDebug ( ) - > additiveMetrics . equals ( <nl> additiveMetricsToCompare ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , TimeInactiveMicrosShouldBeSetUponUnstashAndStash <nl> <nl> / / Time inactive should have increased . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> / / Time inactive should have increased again . <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 200 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction is currently active , so time inactive should not have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 200 } ) ; <nl> <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction is inactive again , so time inactive should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 300 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeInactiveMicrosShouldBeSetUponUnstashAndAbort <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time inactive should be greater than or equal to zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time inactive should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction has aborted , so time inactive should not have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TimeInactiveMicrosShouldIncreaseUntilCommit ) { <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> / / Time inactive should be greater than or equal to zero . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 0 } ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / Time inactive should have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 100 ) ) ; <nl> <nl> / / The transaction has committed , so time inactive should not have increased . <nl> - ASSERT_EQ ( txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> + ASSERT_EQ ( txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> tickSource , tickSource - > getTicks ( ) ) , <nl> Microseconds { 100 } ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , ReportStashedResources ) { <nl> <nl> / / Perform initial unstash which sets up a WriteUnitOfWork . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> ASSERT ( opCtx ( ) - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> TEST_F ( TransactionsMetricsTest , ReportStashedResources ) { <nl> tickSource - > advance ( Microseconds ( preparedDuration ) ) ; <nl> <nl> / / Stash resources . The original Locker and RecoveryUnit now belong to the stash . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> <nl> / / Verify that the Session ' s report of its own stashed state aligns with our expectations . <nl> - auto stashedState = txnParticipant - > reportStashedState ( ) ; <nl> + auto stashedState = txnParticipant . reportStashedState ( opCtx ( ) ) ; <nl> auto transactionDocument = stashedState . getObjectField ( " transaction " ) ; <nl> auto parametersDocument = transactionDocument . getObjectField ( " parameters " ) ; <nl> <nl> TEST_F ( TransactionsMetricsTest , ReportStashedResources ) { <nl> <nl> / / Unstash the stashed resources . This restores the original Locker and RecoveryUnit to the <nl> / / OperationContext . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> <nl> / / With the resources unstashed , verify that the Session reports an empty stashed state . <nl> - ASSERT ( txnParticipant - > reportStashedState ( ) . isEmpty ( ) ) ; <nl> + ASSERT ( txnParticipant . reportStashedState ( opCtx ( ) ) . isEmpty ( ) ) ; <nl> <nl> / / Commit the transaction . This allows us to release locks . <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , ReportUnstashedResources ) { <nl> TEST_F ( TransactionsMetricsTest , ReportUnstashedResources ) { <nl> <nl> / / Perform initial unstash which sets up a WriteUnitOfWork . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> ASSERT ( opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> ASSERT ( opCtx ( ) - > lockState ( ) - > isLocked ( ) ) ; <nl> <nl> / / Prepare transaction and extend duration in the prepared state . <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const long prepareDuration = 10 ; <nl> tickSource - > advance ( Microseconds ( prepareDuration ) ) ; <nl> <nl> / / Verify that the Session ' s report of its own unstashed state aligns with our expectations . <nl> BSONObjBuilder unstashedStateBuilder ; <nl> - txnParticipant - > reportUnstashedState ( opCtx ( ) , & unstashedStateBuilder ) ; <nl> + txnParticipant . reportUnstashedState ( opCtx ( ) , & unstashedStateBuilder ) ; <nl> auto unstashedState = unstashedStateBuilder . obj ( ) ; <nl> auto transactionDocument = unstashedState . getObjectField ( " transaction " ) ; <nl> auto parametersDocument = transactionDocument . getObjectField ( " parameters " ) ; <nl> TEST_F ( TransactionsMetricsTest , ReportUnstashedResources ) { <nl> ASSERT_GTE ( transactionDocument . getField ( " timeInactiveMicros " ) . numberLong ( ) , 0 ) ; <nl> <nl> / / Stash resources . The original Locker and RecoveryUnit now belong to the stash . <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > getWriteUnitOfWork ( ) ) ; <nl> <nl> / / With the resources stashed , verify that the Session reports an empty unstashed state . <nl> BSONObjBuilder builder ; <nl> - txnParticipant - > reportUnstashedState ( opCtx ( ) , & builder ) ; <nl> + txnParticipant . reportUnstashedState ( opCtx ( ) , & builder ) ; <nl> ASSERT ( builder . obj ( ) . isEmpty ( ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , ReportUnstashedResourcesForARetryableWrite ) { <nl> <nl> MongoDOperationContextSession opCtxSession ( opCtx ( ) ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > beginOrContinue ( * opCtx ( ) - > getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> + txnParticipant . beginOrContinue ( opCtx ( ) , * opCtx ( ) - > getTxnNumber ( ) , boost : : none , boost : : none ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " find " ) ; <nl> <nl> / / Build a BSONObj containing the details which we expect to see reported when we invoke <nl> / / reportUnstashedState . For a retryable write , we should only include the txnNumber . <nl> TEST_F ( TransactionsMetricsTest , ReportUnstashedResourcesForARetryableWrite ) { <nl> <nl> / / Verify that the Session ' s report of its own unstashed state aligns with our expectations . <nl> BSONObjBuilder unstashedStateBuilder ; <nl> - txnParticipant - > reportUnstashedState ( opCtx ( ) , & unstashedStateBuilder ) ; <nl> + txnParticipant . reportUnstashedState ( opCtx ( ) , & unstashedStateBuilder ) ; <nl> ASSERT_BSONOBJ_EQ ( unstashedStateBuilder . obj ( ) , reportBuilder . obj ( ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , LastClientInfoShouldUpdateUponStash ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / LastClientInfo should have been set . <nl> - auto lastClientInfo = txnParticipant - > getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> + auto lastClientInfo = txnParticipant . getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> ASSERT_EQ ( lastClientInfo . clientHostAndPort , " " ) ; <nl> ASSERT_EQ ( lastClientInfo . connectionId , 0 ) ; <nl> ASSERT_EQ ( lastClientInfo . appName , " appName " ) ; <nl> TEST_F ( TransactionsMetricsTest , LastClientInfoShouldUpdateUponStash ) { <nl> clientMetadataIsMasterState . setClientMetadata ( opCtx ( ) - > getClient ( ) , <nl> std : : move ( newClientMetadata . getValue ( ) ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> <nl> / / LastClientInfo ' s clientMetadata should have been updated to the new ClientMetadata object . <nl> - lastClientInfo = txnParticipant - > getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> + lastClientInfo = txnParticipant . getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> ASSERT_EQ ( lastClientInfo . appName , " newAppName " ) ; <nl> ASSERT_BSONOBJ_EQ ( lastClientInfo . clientMetadata , newObj . getField ( " client " ) . Obj ( ) ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , LastClientInfoShouldUpdateUponCommit ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> / / The transaction machinery cannot store an empty locker . <nl> Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> / / LastClientInfo should have been set . <nl> - auto lastClientInfo = txnParticipant - > getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> + auto lastClientInfo = txnParticipant . getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> ASSERT_EQ ( lastClientInfo . clientHostAndPort , " " ) ; <nl> ASSERT_EQ ( lastClientInfo . connectionId , 0 ) ; <nl> ASSERT_EQ ( lastClientInfo . appName , " appName " ) ; <nl> TEST_F ( TransactionsMetricsTest , LastClientInfoShouldUpdateUponAbort ) { <nl> <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> <nl> / / LastClientInfo should have been set . <nl> - auto lastClientInfo = txnParticipant - > getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> + auto lastClientInfo = txnParticipant . getSingleTransactionStatsForTest ( ) . getLastClientInfo ( ) ; <nl> ASSERT_EQ ( lastClientInfo . clientHostAndPort , " " ) ; <nl> ASSERT_EQ ( lastClientInfo . connectionId , 0 ) ; <nl> ASSERT_EQ ( lastClientInfo . appName , " appName " ) ; <nl> void buildSingleTransactionStatsString ( StringBuilder * sb , const int metricValue ) <nl> * Builds the time active and time inactive info string . <nl> * / <nl> void buildTimeActiveInactiveString ( StringBuilder * sb , <nl> - TransactionParticipant * txnParticipant , <nl> + TransactionParticipant : : Participant txnParticipant , <nl> TickSource * tickSource , <nl> TickSource : : Tick curTick ) { <nl> / / Add time active micros to string . <nl> ( * sb ) < < " timeActiveMicros : " <nl> < < durationCount < Microseconds > ( <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( tickSource , <nl> - curTick ) ) ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeActiveMicros ( tickSource , <nl> + curTick ) ) ; <nl> <nl> / / Add time inactive micros to string . <nl> ( * sb ) < < " timeInactiveMicros : " <nl> < < durationCount < Microseconds > ( <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( <nl> - tickSource , curTick ) ) ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getTimeInactiveMicros ( tickSource , <nl> + curTick ) ) ; <nl> } <nl> <nl> / * <nl> * Builds the total prepared duration info string . <nl> * / <nl> void buildPreparedDurationString ( StringBuilder * sb , <nl> - TransactionParticipant * txnParticipant , <nl> + TransactionParticipant : : Participant txnParticipant , <nl> TickSource * tickSource , <nl> TickSource : : Tick curTick ) { <nl> ( * sb ) < < " totalPreparedDurationMicros : " <nl> < < durationCount < Microseconds > ( <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getPreparedDuration ( tickSource , <nl> - curTick ) ) ; <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getPreparedDuration ( tickSource , <nl> + curTick ) ) ; <nl> } <nl> <nl> / * <nl> void buildPreparedDurationString ( StringBuilder * sb , <nl> * / <nl> std : : string buildTransactionInfoString ( <nl> OperationContext * opCtx , <nl> - TransactionParticipant * txnParticipant , <nl> + TransactionParticipant : : Participant txnParticipant , <nl> std : : string terminationCause , <nl> const LogicalSessionId sessionId , <nl> const TxnNumber txnNum , <nl> std : : string buildTransactionInfoString ( <nl> StringBuilder readTimestampInfo ; <nl> readTimestampInfo <nl> < < " readTimestamp : " <nl> - < < txnParticipant - > getSpeculativeTransactionReadOpTimeForTest ( ) . getTimestamp ( ) . toString ( ) <nl> + < < txnParticipant . getSpeculativeTransactionReadOpTimeForTest ( ) . getTimestamp ( ) . toString ( ) <nl> < < " , " ; <nl> <nl> StringBuilder singleTransactionStatsInfo ; <nl> std : : string buildTransactionInfoString ( <nl> expectedTransactionInfo < < totalPreparedDuration . str ( ) ; <nl> expectedTransactionInfo < < " prepareOpTime : " <nl> < < ( prepareOpTime ? prepareOpTime - > toString ( ) <nl> - : txnParticipant - > getPrepareOpTime ( ) . toString ( ) ) ; <nl> + : txnParticipant . getPrepareOpTime ( ) . toString ( ) ) ; <nl> } <nl> - if ( txnParticipant - > getOldestOplogEntryOpTimeForTest ( ) ) { <nl> + if ( txnParticipant . getOldestOplogEntryOpTimeForTest ( ) ) { <nl> ASSERT ( ! oldestOplogEntryOpTime ) ; <nl> expectedTransactionInfo < < " oldestOplogEntryOpTime : " <nl> - < < txnParticipant - > getOldestOplogEntryOpTimeForTest ( ) - > toString ( ) ; <nl> + < < txnParticipant . getOldestOplogEntryOpTimeForTest ( ) - > toString ( ) ; <nl> } <nl> if ( oldestOplogEntryOpTime ) { <nl> - ASSERT ( ! txnParticipant - > getOldestOplogEntryOpTimeForTest ( ) ) ; <nl> + ASSERT ( ! txnParticipant . getOldestOplogEntryOpTimeForTest ( ) ) ; <nl> expectedTransactionInfo < < " oldestOplogEntryOpTime : " < < oldestOplogEntryOpTime - > toString ( ) ; <nl> } <nl> - if ( txnParticipant - > getFinishOpTimeForTest ( ) ) { <nl> + if ( txnParticipant . getFinishOpTimeForTest ( ) ) { <nl> expectedTransactionInfo < < " finishOpTime : " <nl> - < < txnParticipant - > getFinishOpTimeForTest ( ) - > toString ( ) ; <nl> + < < txnParticipant . getFinishOpTimeForTest ( ) - > toString ( ) ; <nl> } <nl> expectedTransactionInfo < < " , " <nl> < < duration_cast < Milliseconds > ( <nl> - txnParticipant - > getSingleTransactionStatsForTest ( ) . getDuration ( <nl> + txnParticipant . getSingleTransactionStatsForTest ( ) . getDuration ( <nl> tickSource , tickSource - > getTicks ( ) ) ) ; <nl> return expectedTransactionInfo . str ( ) ; <nl> } <nl> TEST_F ( TransactionsMetricsTest , TestTransactionInfoForLogAfterCommit ) { <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> - std : : string testTransactionInfo = <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , true , readConcernArgs ) ; <nl> + std : : string testTransactionInfo = txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , true , readConcernArgs ) ; <nl> <nl> std : : string expectedTransactionInfo = <nl> buildTransactionInfoString ( opCtx ( ) , <nl> TEST_F ( TransactionsMetricsTest , TestPreparedTransactionInfoForLogAfterCommit ) { <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> tickSource - > advance ( Microseconds ( 10 ) ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> - std : : string testTransactionInfo = <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , true , readConcernArgs ) ; <nl> + std : : string testTransactionInfo = txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , true , readConcernArgs ) ; <nl> <nl> std : : string expectedTransactionInfo = <nl> buildTransactionInfoString ( opCtx ( ) , <nl> TEST_F ( TransactionsMetricsTest , TestTransactionInfoForLogAfterAbort ) { <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> <nl> - std : : string testTransactionInfo = <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , false , readConcernArgs ) ; <nl> + std : : string testTransactionInfo = txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , false , readConcernArgs ) ; <nl> <nl> std : : string expectedTransactionInfo = <nl> buildTransactionInfoString ( opCtx ( ) , <nl> TEST_F ( TransactionsMetricsTest , TestPreparedTransactionInfoForLogAfterAbort ) { <nl> <nl> / / Prepare the transaction and extend the duration in the prepared state . <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> tickSource - > advance ( Microseconds ( 10 ) ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> <nl> - std : : string testTransactionInfo = <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , false , readConcernArgs ) ; <nl> + std : : string testTransactionInfo = txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , false , readConcernArgs ) ; <nl> <nl> std : : string expectedTransactionInfo = <nl> buildTransactionInfoString ( opCtx ( ) , <nl> DEATH_TEST_F ( TransactionsMetricsTest , TestTransactionInfoForLogWithNoLockerInfoS <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > getTransactionInfoForLogForTest ( nullptr , true , readConcernArgs ) ; <nl> + txnParticipant . getTransactionInfoForLogForTest ( opCtx ( ) , nullptr , true , readConcernArgs ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterSlowCommit ) { <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterSlowCommit ) { <nl> const int metricValue = 1 ; <nl> setupAdditiveMetrics ( metricValue , opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> <nl> serverGlobalParams . slowMS = 10 ; <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - txnParticipant - > commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( opCtx ( ) ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> std : : string expectedTransactionInfo = " transaction " + <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , true , readConcernArgs ) ; <nl> + txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , true , readConcernArgs ) ; <nl> ASSERT_EQUALS ( 1 , countLogLinesContaining ( expectedTransactionInfo ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , LogPreparedTransactionInfoAfterSlowCommit ) { <nl> serverGlobalParams . slowMS = 10 ; <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> ASSERT ( lockerInfo ) ; <nl> std : : string expectedTransactionInfo = " transaction " + <nl> - txnParticipant - > getTransactionInfoForLogForTest ( & lockerInfo - > stats , true , readConcernArgs ) ; <nl> + txnParticipant . getTransactionInfoForLogForTest ( <nl> + opCtx ( ) , & lockerInfo - > stats , true , readConcernArgs ) ; <nl> ASSERT_EQUALS ( 1 , countLogLinesContaining ( expectedTransactionInfo ) ) ; <nl> } <nl> <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterSlowAbort ) { <nl> const int metricValue = 1 ; <nl> setupAdditiveMetrics ( metricValue , opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> <nl> serverGlobalParams . slowMS = 10 ; <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> TEST_F ( TransactionsMetricsTest , LogPreparedTransactionInfoAfterSlowAbort ) { <nl> const int metricValue = 1 ; <nl> setupAdditiveMetrics ( metricValue , opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> serverGlobalParams . slowMS = 10 ; <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> - auto prepareOpTime = txnParticipant - > getPrepareOpTime ( ) ; <nl> + auto prepareOpTime = txnParticipant . getPrepareOpTime ( ) ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterExceptionInPrepare ) { <nl> const int metricValue = 1 ; <nl> setupAdditiveMetrics ( metricValue , opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> serverGlobalParams . slowMS = 10 ; <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> <nl> _opObserver - > onTransactionPrepareThrowsException = true ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . prepareTransaction ( opCtx ( ) , { } ) , <nl> AssertionException , <nl> ErrorCodes : : OperationFailed ) ; <nl> ASSERT_FALSE ( _opObserver - > transactionPrepared ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> const auto lockerInfo = opCtx ( ) - > lockState ( ) - > getLockerInfo ( boost : : none ) ; <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterSlowStashedAbort ) { <nl> const int metricValue = 1 ; <nl> setupAdditiveMetrics ( metricValue , opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> <nl> { Lock : : GlobalLock lk ( opCtx ( ) , MODE_IX , Date_t : : now ( ) , Lock : : InterruptBehavior : : kThrow ) ; } <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> - const auto txnResourceStashLocker = txnParticipant - > getTxnResourceStashLockerForTest ( ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> + const auto txnResourceStashLocker = txnParticipant . getTxnResourceStashLockerForTest ( ) ; <nl> ASSERT ( txnResourceStashLocker ) ; <nl> const auto lockerInfo = txnResourceStashLocker - > getLockerInfo ( boost : : none ) ; <nl> <nl> TEST_F ( TransactionsMetricsTest , LogTransactionInfoAfterSlowStashedAbort ) { <nl> tickSource - > advance ( Microseconds ( 11 * 1000 ) ) ; <nl> <nl> startCapturingLogMessages ( ) ; <nl> - txnParticipant - > abortArbitraryTransaction ( ) ; <nl> + txnParticipant . abortTransactionIfNotPrepared ( opCtx ( ) ) ; <nl> stopCapturingLogMessages ( ) ; <nl> <nl> std : : string expectedTransactionInfo = " transaction parameters " ; <nl> TEST_F ( TxnParticipantTest , WhenOldestTSRemovedNextOldestBecomesNewOldest ) { <nl> / / Check that there are no Timestamps in the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 0U ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - auto firstPrepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + auto firstPrepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> / / Check that we added a Timestamp to the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> / / Check that the oldest prepareTimestamp is equal to firstPrepareTimestamp because there is <nl> / / only one prepared transaction on this Service . <nl> auto prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , firstPrepareTimestamp ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> auto originalClient = Client : : releaseCurrent ( ) ; <nl> <nl> / * * <nl> TEST_F ( TxnParticipantTest , WhenOldestTSRemovedNextOldestBecomesNewOldest ) { <nl> <nl> MongoDOperationContextSession newOpCtxSession ( newOpCtx . get ( ) ) ; <nl> auto newTxnParticipant = TransactionParticipant : : get ( newOpCtx . get ( ) ) ; <nl> - newTxnParticipant - > beginOrContinue ( newTxnNum , false , true ) ; <nl> - newTxnParticipant - > unstashTransactionResources ( newOpCtx . get ( ) , " prepareTransaction " ) ; <nl> + newTxnParticipant . beginOrContinue ( newOpCtx . get ( ) , newTxnNum , false , true ) ; <nl> + newTxnParticipant . unstashTransactionResources ( newOpCtx . get ( ) , " prepareTransaction " ) ; <nl> <nl> / / secondPrepareTimestamp should be greater than firstPreparedTimestamp because this <nl> / / transaction was prepared after . <nl> - secondPrepareTimestamp = newTxnParticipant - > prepareTransaction ( newOpCtx . get ( ) , { } ) ; <nl> + secondPrepareTimestamp = newTxnParticipant . prepareTransaction ( newOpCtx . get ( ) , { } ) ; <nl> ASSERT_GT ( secondPrepareTimestamp , firstPrepareTimestamp ) ; <nl> / / Check that we added a Timestamp to the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 2U ) ; <nl> / / The oldest prepareTimestamp should still be firstPrepareTimestamp . <nl> prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , firstPrepareTimestamp ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> Client : : releaseCurrent ( ) ; <nl> TEST_F ( TxnParticipantTest , WhenOldestTSRemovedNextOldestBecomesNewOldest ) { <nl> <nl> / / Switch clients and abort the first transaction . This should cause the oldestActiveTS to be <nl> / / equal to the secondPrepareTimestamp . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> prepareOpTime = ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ; <nl> ASSERT_EQ ( prepareOpTime - > getTimestamp ( ) , secondPrepareTimestamp ) ; <nl> TEST_F ( TxnParticipantTest , ReturnNullTimestampIfNoOldestActiveTimestamp ) { <nl> / / Check that there are no Timestamps in the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 0U ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> / / Check that we added a Timestamp to the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( opCtx ( ) ) ; <nl> + txnParticipant . stashTransactionResources ( opCtx ( ) ) ; <nl> auto originalClient = Client : : releaseCurrent ( ) ; <nl> <nl> / * * <nl> TEST_F ( TxnParticipantTest , ReturnNullTimestampIfNoOldestActiveTimestamp ) { <nl> <nl> MongoDOperationContextSession newOpCtxSession ( newOpCtx . get ( ) ) ; <nl> auto newTxnParticipant = TransactionParticipant : : get ( newOpCtx . get ( ) ) ; <nl> - newTxnParticipant - > beginOrContinue ( newTxnNum , false , true ) ; <nl> - newTxnParticipant - > unstashTransactionResources ( newOpCtx . get ( ) , " prepareTransaction " ) ; <nl> + newTxnParticipant . beginOrContinue ( newOpCtx . get ( ) , newTxnNum , false , true ) ; <nl> + newTxnParticipant . unstashTransactionResources ( newOpCtx . get ( ) , " prepareTransaction " ) ; <nl> <nl> / / secondPrepareTimestamp should be greater than firstPreparedTimestamp because this <nl> / / transaction was prepared after . <nl> - newTxnParticipant - > prepareTransaction ( newOpCtx . get ( ) , { } ) ; <nl> + newTxnParticipant . prepareTransaction ( newOpCtx . get ( ) , { } ) ; <nl> / / Check that we added a Timestamp to the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 2U ) ; <nl> / / The oldest prepareTimestamp should still be firstPrepareTimestamp . <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> / / Abort this transaction and check that we have decremented the total active timestamps <nl> / / count . <nl> - newTxnParticipant - > abortActiveTransaction ( newOpCtx . get ( ) ) ; <nl> + newTxnParticipant . abortActiveTransaction ( newOpCtx . get ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , ReturnNullTimestampIfNoOldestActiveTimestamp ) { <nl> <nl> / / Switch clients and abort the first transaction . This means we no longer have an oldest active <nl> / / timestamp . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 0U ) ; <nl> ASSERT_FALSE ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , ProperlyMaintainOldestNonMajorityCommittedOpTimeSet ) <nl> / / Check that there are no Timestamps in the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 0U ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " prepareTransaction " ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> / / Check that we added a Timestamp to the set . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> <nl> TEST_F ( TxnParticipantTest , ProperlyMaintainOldestNonMajorityCommittedOpTimeSet ) <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getFinishOpTimeOfOldestNonMajCommitted_forTest ( ) ; <nl> ASSERT_EQ ( nonMajorityCommittedOpTimeFinishOpTime - > getTimestamp ( ) , Timestamp : : max ( ) ) ; <nl> <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> / / Since this test uses a mock opObserver , we have to manually set the finishTimestamp on the <nl> / / txnParticipant . <nl> auto finishOpTime = repl : : OpTime ( { 10 , 10 } , 0 ) ; <nl> repl : : ReplClientInfo : : forClient ( opCtx ( ) - > getClient ( ) ) . setLastOp ( finishOpTime ) ; <nl> <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> / / Make sure that we moved the OpTime from the oldestActiveOplogEntryOpTimes to <nl> / / oldestNonMajorityCommittedOpTimes along with the abort / commit oplog entry OpTime <nl> TEST_F ( TxnParticipantTest , RollbackResetsInMemoryStateOfPreparedTransaction ) { <nl> ASSERT_FALSE ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestNonMajorityCommittedOpTime ( ) ) ; <nl> <nl> / / Perform an insert as a part of a transaction so that we have a transaction operation . <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " insert " ) ; <nl> auto operation = repl : : OplogEntry : : makeInsertOperation ( kNss , kUUID , BSON ( " TestValue " < < 0 ) ) ; <nl> - txnParticipant - > addTransactionOperation ( opCtx ( ) , operation ) ; <nl> + txnParticipant . addTransactionOperation ( opCtx ( ) , operation ) ; <nl> ASSERT_BSONOBJ_EQ ( operation . toBSON ( ) , <nl> - txnParticipant - > getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> + txnParticipant . getTransactionOperationsForTest ( ) [ 0 ] . toBSON ( ) ) ; <nl> <nl> - auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , { } ) ; <nl> + auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , { } ) ; <nl> <nl> / / Check that we added a Timestamp to oldestActiveOplogEntryOpTimes . <nl> ASSERT_EQ ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getTotalActiveOpTimes ( ) , 1U ) ; <nl> TEST_F ( TxnParticipantTest , RollbackResetsInMemoryStateOfPreparedTransaction ) { <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestNonMajorityCommittedOpTime ( ) ; <nl> ASSERT_EQ ( oldestActiveOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> ASSERT_EQ ( oldestNonMajorityCommittedOpTime - > getTimestamp ( ) , prepareTimestamp ) ; <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> <nl> / / Make sure the state of txnParticipant is populated correctly after a prepared transaction . <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getTransactionOperationsForTest ( ) . size ( ) , 1U ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) . getTimestamp ( ) , prepareTimestamp ) ; <nl> - ASSERT_NE ( txnParticipant - > getActiveTxnNumber ( ) , kUninitializedTxnNumber ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getTransactionOperationsForTest ( ) . size ( ) , 1U ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) . getTimestamp ( ) , prepareTimestamp ) ; <nl> + ASSERT_NE ( txnParticipant . getActiveTxnNumber ( ) , kUninitializedTxnNumber ) ; <nl> <nl> - txnParticipant - > abortPreparedTransactionForRollback ( ) ; <nl> + txnParticipant . abortPreparedTransactionForRollback ( opCtx ( ) ) ; <nl> ServerTransactionsMetrics : : get ( opCtx ( ) ) - > clearOpTimes ( ) ; <nl> <nl> / / After calling abortPreparedTransactionForRollback , the state of txnParticipant should be <nl> / / invalidated . <nl> - ASSERT_FALSE ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getTransactionOperationsForTest ( ) . size ( ) , 0U ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) . getTimestamp ( ) , Timestamp ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getActiveTxnNumber ( ) , kUninitializedTxnNumber ) ; <nl> + ASSERT_FALSE ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getTransactionOperationsForTest ( ) . size ( ) , 0U ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) . getTimestamp ( ) , Timestamp ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getActiveTxnNumber ( ) , kUninitializedTxnNumber ) ; <nl> <nl> / / After calling clearOpTimes , we should no longer have an oldestActiveOpTime . <nl> ASSERT_FALSE ( ServerTransactionsMetrics : : get ( opCtx ( ) ) - > getOldestActiveOpTime ( ) ) ; <nl> TEST_F ( TxnParticipantTest , PrepareTransactionAsSecondarySetsThePrepareOpTime ) { <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> ASSERT_EQ ( prepareTimestamp , prepareOpTime . getTimestamp ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) , prepareOpTime ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) , prepareOpTime ) ; <nl> <nl> / / If _prepareOptime was not set and was null , then commitPreparedTransaction would falsely <nl> / / succeed everytime . We set the commitTimestamp to be less than the prepareTimestamp to make <nl> / / sure this is not the case . <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) - 1 ) ; <nl> - ASSERT_THROWS_CODE ( txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) , <nl> + ASSERT_THROWS_CODE ( txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) , <nl> AssertionException , <nl> ErrorCodes : : InvalidOptions ) ; <nl> } <nl> TEST_F ( TxnParticipantTest , CommitPreparedTransactionAsSecondarySetsTheFinishOpTi <nl> repl : : UnreplicatedWritesBlock uwb ( opCtx ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > writesAreReplicated ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> ASSERT_EQ ( prepareTimestamp , prepareOpTime . getTimestamp ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) , prepareOpTime ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) , prepareOpTime ) ; <nl> <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> const auto commitOplogEntryOpTime = repl : : OpTime ( { 10 , 10 } , 0 ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , commitOplogEntryOpTime ) ; <nl> - ASSERT_EQ ( txnParticipant - > getFinishOpTimeForTest ( ) . get ( ) , commitOplogEntryOpTime ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsCommitted ( ) ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , commitOplogEntryOpTime ) ; <nl> + ASSERT_EQ ( txnParticipant . getFinishOpTimeForTest ( ) . get ( ) , commitOplogEntryOpTime ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsCommitted ( ) ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TxnParticipantTest , <nl> DEATH_TEST_F ( TxnParticipantTest , <nl> repl : : UnreplicatedWritesBlock uwb ( opCtx ( ) ) ; <nl> ASSERT ( ! opCtx ( ) - > writesAreReplicated ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> ASSERT_EQ ( prepareTimestamp , prepareOpTime . getTimestamp ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) , prepareOpTime ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) , prepareOpTime ) ; <nl> <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , { } ) ; <nl> } <nl> <nl> DEATH_TEST_F ( TxnParticipantTest , <nl> DEATH_TEST_F ( TxnParticipantTest , <nl> auto sessionCheckout = checkOutSession ( ) ; <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> - const auto prepareTimestamp = txnParticipant - > prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> - ASSERT ( txnParticipant - > transactionIsPrepared ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " commitTransaction " ) ; <nl> + const auto prepareTimestamp = txnParticipant . prepareTransaction ( opCtx ( ) , prepareOpTime ) ; <nl> + ASSERT ( txnParticipant . transactionIsPrepared ( ) ) ; <nl> ASSERT_EQ ( prepareTimestamp , prepareOpTime . getTimestamp ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getPrepareOpTime ( ) , prepareOpTime ) ; <nl> + ASSERT_EQ ( txnParticipant . getPrepareOpTime ( ) , prepareOpTime ) ; <nl> <nl> const auto commitTimestamp = <nl> Timestamp ( prepareTimestamp . getSecs ( ) , prepareTimestamp . getInc ( ) + 1 ) ; <nl> const auto commitOplogEntryOpTime = repl : : OpTime ( { 10 , 10 } , 0 ) ; <nl> - txnParticipant - > commitPreparedTransaction ( opCtx ( ) , commitTimestamp , commitOplogEntryOpTime ) ; <nl> + txnParticipant . commitPreparedTransaction ( opCtx ( ) , commitTimestamp , commitOplogEntryOpTime ) ; <nl> } <nl> <nl> TEST_F ( TxnParticipantTest , AbortTransactionOnSessionCheckoutWithoutRefresh ) { <nl> TEST_F ( TxnParticipantTest , AbortTransactionOnSessionCheckoutWithoutRefresh ) { <nl> MongoDOperationContextSessionWithoutRefresh sessionCheckout ( opCtx ( ) ) ; <nl> <nl> auto txnParticipant = TransactionParticipant : : get ( opCtx ( ) ) ; <nl> - ASSERT ( txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> - ASSERT_EQ ( txnParticipant - > getActiveTxnNumber ( ) , txnNumber ) ; <nl> + ASSERT ( txnParticipant . inMultiDocumentTransaction ( ) ) ; <nl> + ASSERT_EQ ( txnParticipant . getActiveTxnNumber ( ) , txnNumber ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> - txnParticipant - > abortActiveTransaction ( opCtx ( ) ) ; <nl> - ASSERT_TRUE ( txnParticipant - > transactionIsAborted ( ) ) ; <nl> + txnParticipant . unstashTransactionResources ( opCtx ( ) , " abortTransaction " ) ; <nl> + txnParticipant . abortActiveTransaction ( opCtx ( ) ) ; <nl> + ASSERT_TRUE ( txnParticipant . transactionIsAborted ( ) ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / src / mongo / dbtests / storage_timestamp_tests . cpp <nl> ppp b / src / mongo / dbtests / storage_timestamp_tests . cpp <nl> class MultiDocumentTransactionTest : public StorageTimestampTest { <nl> auto txnParticipant = TransactionParticipant : : get ( _opCtx ) ; <nl> ASSERT ( txnParticipant ) ; <nl> <nl> - txnParticipant - > beginOrContinue ( <nl> - * _opCtx - > getTxnNumber ( ) , false / * autocommit * / , true / * startTransaction * / ) ; <nl> - txnParticipant - > unstashTransactionResources ( _opCtx , " insert " ) ; <nl> + txnParticipant . beginOrContinue ( <nl> + _opCtx , * _opCtx - > getTxnNumber ( ) , false / * autocommit * / , true / * startTransaction * / ) ; <nl> + txnParticipant . unstashTransactionResources ( _opCtx , " insert " ) ; <nl> { <nl> AutoGetCollection autoColl ( _opCtx , nss , LockMode : : MODE_IX , LockMode : : MODE_IX ) ; <nl> insertDocument ( autoColl . getCollection ( ) , InsertStatement ( doc ) ) ; <nl> } <nl> - txnParticipant - > stashTransactionResources ( _opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( _opCtx ) ; <nl> <nl> { <nl> AutoGetCollection autoColl ( _opCtx , nss , LockMode : : MODE_IS , LockMode : : MODE_IS ) ; <nl> class MultiDocumentTransaction : public MultiDocumentTransactionTest { <nl> ASSERT ( txnParticipant ) ; <nl> logTimestamps ( ) ; <nl> <nl> - txnParticipant - > unstashTransactionResources ( _opCtx , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( _opCtx , " insert " ) ; <nl> <nl> - txnParticipant - > commitUnpreparedTransaction ( _opCtx ) ; <nl> + txnParticipant . commitUnpreparedTransaction ( _opCtx ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( _opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( _opCtx ) ; <nl> { <nl> AutoGetCollection autoColl ( _opCtx , nss , LockMode : : MODE_X , LockMode : : MODE_IX ) ; <nl> auto coll = autoColl . getCollection ( ) ; <nl> class PreparedMultiDocumentTransaction : public MultiDocumentTransactionTest { <nl> assertOplogDocumentExistsAtTimestamp ( commitFilter , commitEntryTs , false ) ; <nl> assertOplogDocumentExistsAtTimestamp ( commitFilter , commitTimestamp , false ) ; <nl> } <nl> - txnParticipant - > unstashTransactionResources ( _opCtx , " insert " ) ; <nl> + txnParticipant . unstashTransactionResources ( _opCtx , " insert " ) ; <nl> <nl> - txnParticipant - > prepareTransaction ( _opCtx , { } ) ; <nl> + txnParticipant . prepareTransaction ( _opCtx , { } ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( _opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( _opCtx ) ; <nl> { <nl> const auto prepareFilter = BSON ( " ts " < < prepareTs ) ; <nl> assertOplogDocumentExistsAtTimestamp ( prepareFilter , presentTs , false ) ; <nl> class PreparedMultiDocumentTransaction : public MultiDocumentTransactionTest { <nl> assertOplogDocumentExistsAtTimestamp ( commitFilter , commitTimestamp , false ) ; <nl> assertOplogDocumentExistsAtTimestamp ( commitFilter , nullTs , false ) ; <nl> } <nl> - txnParticipant - > unstashTransactionResources ( _opCtx , " commitTransaction " ) ; <nl> + txnParticipant . unstashTransactionResources ( _opCtx , " commitTransaction " ) ; <nl> <nl> - txnParticipant - > commitPreparedTransaction ( _opCtx , commitTimestamp , { } ) ; <nl> + txnParticipant . commitPreparedTransaction ( _opCtx , commitTimestamp , { } ) ; <nl> <nl> - txnParticipant - > stashTransactionResources ( _opCtx ) ; <nl> + txnParticipant . stashTransactionResources ( _opCtx ) ; <nl> { <nl> AutoGetCollection autoColl ( _opCtx , nss , LockMode : : MODE_X , LockMode : : MODE_IX ) ; <nl> auto coll = autoColl . getCollection ( ) ; <nl> | SERVER - 38810 Use Session ' s concurrency control rules instead of internal mutexes in TransactionParticipant | mongodb/mongo | 1d246814a058073f0c26981fff5fe67c16af3593 | 2019-02-15T16:48:50Z |
mmm a / cmake / ConfigureCompiler . cmake <nl> ppp b / cmake / ConfigureCompiler . cmake <nl> set ( CMAKE_REQUIRED_LIBRARIES c ) <nl> <nl> <nl> if ( WIN32 ) <nl> - add_compile_options ( / W3 / EHsc / std : c + + 14 / bigobj / Zi ) <nl> + add_compile_options ( / W3 / EHsc / std : c + + 14 / bigobj $ < $ < CONFIG : Release > : / Zi > ) <nl> else ( ) <nl> if ( USE_GOLD_LINKER ) <nl> set ( CMAKE_EXE_LINKER_FLAGS " $ { CMAKE_EXE_LINKER_FLAGS } - fuse - ld = gold - Wl , - - disable - new - dtags " ) <nl> | Update cmake / ConfigureCompiler . cmake | apple/foundationdb | 590863479bd86e1491962ba94a222aaf135d2706 | 2019-03-05T22:58:44Z |
mmm a / contrib / libtcmalloc / CMakeLists . txt <nl> ppp b / contrib / libtcmalloc / CMakeLists . txt <nl> <nl> add_definitions ( <nl> - - DNO_TCMALLOC_SAMPLES - DNO_TCMALLOC_SAMPLES <nl> + - DNO_TCMALLOC_SAMPLES <nl> - DNDEBUG - DNO_FRAME_POINTER <nl> - Wwrite - strings - Wno - sign - compare - Wno - unused - result <nl> - Wno - deprecated - declarations - Wno - unused - function <nl> mmm a / dbms / CMakeLists . txt <nl> ppp b / dbms / CMakeLists . txt <nl> include_directories ( BEFORE $ { ClickHouse_SOURCE_DIR } / contrib / libre2 / ) <nl> include_directories ( BEFORE $ { ClickHouse_BINARY_DIR } / contrib / libre2 / ) <nl> include_directories ( $ { ClickHouse_SOURCE_DIR } / libs / libdaemon / include / ) <nl> <nl> - if ( NOT ENABLE_LIBTCMALLOC ) <nl> - add_definitions ( - DNO_TCMALLOC ) <nl> - endif ( ) <nl> - <nl> if ( NOT NO_WERROR ) <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - Werror " ) <nl> set ( CMAKE_C_FLAGS " $ { CMAKE_C_FLAGS } - Werror " ) <nl> mmm a / dbms / src / Interpreters / AsynchronousMetrics . cpp <nl> ppp b / dbms / src / Interpreters / AsynchronousMetrics . cpp <nl> <nl> # include < DB / Databases / IDatabase . h > <nl> # include < chrono > <nl> <nl> - # ifndef NO_TCMALLOC <nl> + # include < common / config_common . h > <nl> + <nl> + # if ENABLE_LIBTCMALLOC <nl> # include < gperftools / malloc_extension . h > <nl> <nl> / / / Initializing malloc extension in global constructor as required . <nl> void AsynchronousMetrics : : update ( ) <nl> set ( " MaxPartCountForPartition " , max_part_count_for_partition ) ; <nl> } <nl> <nl> - # ifndef NO_TCMALLOC <nl> + # if ENABLE_LIBTCMALLOC <nl> { <nl> / / / tcmalloc related metrics . Remove if you switch to different allocator . <nl> <nl> mmm a / dbms / src / Server / main . cpp <nl> ppp b / dbms / src / Server / main . cpp <nl> <nl> - # ifndef NO_TCMALLOC <nl> + # include < common / config_common . h > <nl> + # if ENABLE_LIBTCMALLOC <nl> # include < gperftools / malloc_extension . h > <nl> # endif <nl> # include " Server . h " <nl> static bool isClickhouseApp ( const std : : string & app_suffix , std : : vector < char * > <nl> <nl> int main ( int argc_ , char * * argv_ ) <nl> { <nl> - # ifndef NO_TCMALLOC <nl> + # if ENABLE_LIBTCMALLOC <nl> MallocExtension : : instance ( ) - > SetNumericProperty ( " tcmalloc . aggressive_memory_decommit " , false ) ; <nl> # endif <nl> <nl> mmm a / libs / libcommon / include / common / config_common . h . in <nl> ppp b / libs / libcommon / include / common / config_common . h . in <nl> <nl> / / . h autogenerated by cmake ! <nl> <nl> # cmakedefine01 APPLE_SIERRA_OR_NEWER <nl> + # cmakedefine01 ENABLE_LIBTCMALLOC <nl> | cmake : remove add_definitions ( - DNO_TCMALLOC ) , instead use ENABLE_LIBTCMALLOC from config ( ) | ClickHouse/ClickHouse | 2688f4563f2514f515389c2a2ec77f6c7638a4d8 | 2017-01-20T17:58:07Z |
mmm a / lib / AST / Verifier . cpp <nl> ppp b / lib / AST / Verifier . cpp <nl> <nl> # include " swift / AST / AST . h " <nl> # include " swift / AST / ASTVisitor . h " <nl> # include " swift / AST / Verifier . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> using namespace swift ; <nl> <nl> namespace { <nl> namespace { <nl> class Verifier { <nl> ASTContext & Context ; <nl> VerificationKind Stage ; <nl> + llvm : : raw_ostream & Out ; <nl> + <nl> public : <nl> Verifier ( ASTContext & Context , VerificationKind Stage ) <nl> - : Context ( Context ) , Stage ( Stage ) { } <nl> + : Context ( Context ) , Stage ( Stage ) , Out ( llvm : : errs ( ) ) { } <nl> <nl> - Expr * dispatch ( Expr * E , WalkOrder Ord ) { <nl> + Expr * dispatch ( Expr * E , WalkOrder ord ) { <nl> switch ( E - > getKind ( ) ) { <nl> - # define DISPATCH ( ID ) visit ( static_cast < ID # # Expr * > ( E ) , Ord ) ; <nl> + # define DISPATCH ( ID ) return dispatchVisit ( static_cast < ID # # Expr * > ( E ) , ord ) <nl> # define EXPR ( ID , PARENT ) \ <nl> case ExprKind : : ID : \ <nl> - return DISPATCH ( ID ) ; <nl> + DISPATCH ( ID ) ; <nl> # define UNCHECKED_EXPR ( ID , PARENT ) \ <nl> case ExprKind : : ID : \ <nl> assert ( Stage < VerificationKind : : CheckedTypes & & # ID " in wrong phase " ) ; \ <nl> - return DISPATCH ( ID ) ; <nl> + DISPATCH ( ID ) ; <nl> # define UNBOUND_EXPR ( ID , PARENT ) \ <nl> case ExprKind : : ID : \ <nl> assert ( Stage < VerificationKind : : BoundNames & & # ID " in wrong phase " ) ; \ <nl> - return DISPATCH ( ID ) ; <nl> + DISPATCH ( ID ) ; <nl> # include " swift / AST / ExprNodes . def " <nl> # undef DISPATCH <nl> } <nl> llvm_unreachable ( " not all cases handled ! " ) ; <nl> } <nl> <nl> - Stmt * dispatch ( Stmt * S , WalkOrder Ord ) { <nl> + Stmt * dispatch ( Stmt * S , WalkOrder ord ) { <nl> switch ( S - > getKind ( ) ) { <nl> - # define DISPATCH ( ID ) visit ( static_cast < ID # # Stmt * > ( S ) , Ord ) ; <nl> + # define DISPATCH ( ID ) return dispatchVisit ( static_cast < ID # # Stmt * > ( S ) , ord ) <nl> # define STMT ( ID , PARENT ) \ <nl> case StmtKind : : ID : \ <nl> - return DISPATCH ( ID ) ; <nl> + DISPATCH ( ID ) ; <nl> # include " swift / AST / StmtNodes . def " <nl> # undef DISPATCH <nl> } <nl> llvm_unreachable ( " not all cases handled ! " ) ; <nl> } <nl> <nl> - Expr * visit ( Expr * E , WalkOrder Ord ) { return E ; } <nl> - Stmt * visit ( Stmt * S , WalkOrder Ord ) { return S ; } <nl> + private : <nl> + / / / Helper template for dispatching visitation . <nl> + template < class T > T dispatchVisit ( T node , WalkOrder ord ) { <nl> + / / If we ' re visiting in pre - order , don ' t validate the node yet ; <nl> + / / just check whether we should stop further descent . <nl> + if ( ord = = WalkOrder : : PreOrder ) <nl> + return ( shouldVerify ( node ) ? node : T ( ) ) ; <nl> + <nl> + / / Otherwise , actually verify the node . <nl> + <nl> + / / Always verify the node as a parsed node . <nl> + verifyParsed ( node ) ; <nl> + <nl> + / / If we ' ve bound names already , verify as a bound node . <nl> + if ( Stage > = VerificationKind : : BoundNames ) <nl> + verifyBound ( node ) ; <nl> + <nl> + / / If we ' ve checked types already , do some extra verification . <nl> + if ( Stage > = VerificationKind : : CheckedTypes ) <nl> + verifyChecked ( node ) ; <nl> + <nl> + / / Always continue . <nl> + return node ; <nl> + } <nl> + <nl> + / / Default cases for whether we should verify within the given subtree . <nl> + bool shouldVerify ( Expr * E ) { return true ; } <nl> + bool shouldVerify ( Stmt * S ) { return true ; } <nl> + <nl> + / / Base cases for the various stages of verification . <nl> + void verifyParsed ( Expr * E ) { } <nl> + void verifyParsed ( Stmt * S ) { } <nl> + void verifyBound ( Expr * E ) { } <nl> + void verifyBound ( Stmt * S ) { } <nl> + void verifyChecked ( Expr * E ) { } <nl> + void verifyChecked ( Stmt * S ) { } <nl> + <nl> + / / Specialized verifiers . <nl> + <nl> + void verifyChecked ( AssignStmt * S ) { <nl> + checkSameType ( S - > getDest ( ) - > getType ( ) , S - > getSrc ( ) - > getType ( ) , <nl> + " assignment operands " ) ; <nl> + } <nl> + <nl> + / / Verification utilities . <nl> + void checkSameType ( Type T0 , Type T1 , const char * what ) { <nl> + if ( T0 - > getCanonicalType ( Context ) = = T1 - > getCanonicalType ( Context ) ) <nl> + return ; <nl> + <nl> + Out < < " different types for " < < what < < " : " ; <nl> + T0 . print ( Out ) ; <nl> + Out < < " vs . " ; <nl> + T1 . print ( Out ) ; <nl> + Out < < " \ n " ; <nl> + abort ( ) ; <nl> + } <nl> } ; <nl> } <nl> <nl> | Simplify adding new verifications by stage . Add a | apple/swift | 709177e000fd79aa1fe4a446b8ee415ce389d78a | 2011-09-24T09:28:42Z |
mmm a / third_party / fbgemm <nl> ppp b / third_party / fbgemm <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 14adee1ac506e067489406af689ae9b73fb581bd <nl> + Subproject commit b96bc0bf311f7abdc83ffd3af0a485b4aef53f7c <nl> | fbgemm submodule update ( ) | pytorch/pytorch | 2398a3255eed2750ebe62f467d40ba5fc0211a33 | 2018-11-06T01:39:20Z |
mmm a / Telegram / SourceFiles / apiwrap . cpp <nl> ppp b / Telegram / SourceFiles / apiwrap . cpp <nl> void ApiWrap : : sendUploadedDocument ( <nl> } <nl> } <nl> <nl> - void ApiWrap : : editUploadedPhoto ( <nl> - FullMsgId localId , <nl> - const MTPInputFile & file , <nl> - bool silent ) { <nl> - if ( const auto item = App : : histItemById ( localId ) ) { <nl> - const auto media = MTP_inputMediaUploadedPhoto ( <nl> - MTP_flags ( 0 ) , <nl> - file , <nl> - MTPVector < MTPInputDocument > ( ) , <nl> - MTP_int ( 0 ) ) ; <nl> - <nl> - auto flagsEditMsg = MTPmessages_EditMessage : : Flag : : f_message | 0 ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_no_webpage ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_entities ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_media ; <nl> - <nl> - auto sentEntities = TextUtilities : : EntitiesToMTP ( <nl> - item - > originalText ( ) . entities , <nl> - TextUtilities : : ConvertOption : : SkipLocal ) ; <nl> - <nl> - request ( MTPmessages_EditMessage ( <nl> - MTP_flags ( flagsEditMsg ) , <nl> - item - > history ( ) - > peer - > input , <nl> - MTP_int ( item - > id ) , <nl> - MTP_string ( item - > originalText ( ) . text ) , <nl> - media , <nl> - MTPReplyMarkup ( ) , <nl> - sentEntities <nl> - ) ) . done ( [ = ] ( const MTPUpdates & result ) { <nl> - item - > clearSavedMedia ( ) ; <nl> - item - > setIsLocalUpdateMedia ( true ) ; <nl> - applyUpdates ( result ) ; <nl> - } ) . fail ( [ = ] ( const RPCError & error ) { <nl> - QString err = error . type ( ) ; <nl> - if ( err = = qstr ( " MESSAGE_NOT_MODIFIED " ) <nl> - | | err = = qstr ( " MEDIA_NEW_INVALID " ) ) { <nl> - item - > returnSavedMedia ( ) ; <nl> - _session - > data ( ) . sendHistoryChangeNotifications ( ) ; <nl> - } else { <nl> - sendMessageFail ( error ) ; <nl> - } <nl> - } ) . send ( ) ; <nl> - } <nl> - } <nl> - <nl> - void ApiWrap : : editUploadedDocument ( <nl> + void ApiWrap : : editUploadedFile ( <nl> FullMsgId localId , <nl> const MTPInputFile & file , <nl> const std : : optional < MTPInputFile > & thumb , <nl> - bool silent ) { <nl> - if ( const auto item = App : : histItemById ( localId ) ) { <nl> - QString filename = " file " ; <nl> - if ( const auto document = item - > media ( ) - > document ( ) ) { <nl> - filename = document - > filename ( ) ; <nl> + bool silent , <nl> + bool isDocument ) { <nl> + const auto item = App : : histItemById ( localId ) ; <nl> + if ( ! item ) { <nl> + return ; <nl> + } <nl> <nl> - const auto filenameAttribute = MTP_documentAttributeFilename ( <nl> - MTP_string ( filename ) ) ; <nl> - auto attributes = QVector < MTPDocumentAttribute > ( 1 , filenameAttribute ) ; <nl> + auto sentEntities = TextUtilities : : EntitiesToMTP ( <nl> + item - > originalText ( ) . entities , <nl> + TextUtilities : : ConvertOption : : SkipLocal ) ; <nl> <nl> - const auto groupId = item - > groupId ( ) ; <nl> - const auto flags = MTPDinputMediaUploadedDocument : : Flags ( 0 ) <nl> - | ( thumb <nl> - ? MTPDinputMediaUploadedDocument : : Flag : : f_thumb <nl> - : MTPDinputMediaUploadedDocument : : Flag ( 0 ) ) <nl> - / / Never edit video as gif . <nl> - | MTPDinputMediaUploadedDocument : : Flag : : f_nosound_video ; <nl> - const auto media = MTP_inputMediaUploadedDocument ( <nl> - MTP_flags ( flags ) , <nl> - file , <nl> - thumb ? * thumb : MTPInputFile ( ) , <nl> - MTP_string ( document - > mimeString ( ) ) , <nl> - ComposeSendingDocumentAttributes ( document ) , <nl> - MTPVector < MTPInputDocument > ( ) , <nl> - MTP_int ( 0 ) ) ; <nl> + auto flagsEditMsg = MTPmessages_EditMessage : : Flag : : f_message | 0 ; <nl> + flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_no_webpage ; <nl> + flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_entities ; <nl> + flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_media ; <nl> <nl> - auto flagsEditMsg = MTPmessages_EditMessage : : Flag : : f_message | 0 ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_no_webpage ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_entities ; <nl> - flagsEditMsg | = MTPmessages_EditMessage : : Flag : : f_media ; <nl> + MTPinputMedia media = MTP_inputMediaEmpty ( ) ; <nl> <nl> - auto sentEntities = TextUtilities : : EntitiesToMTP ( <nl> - item - > originalText ( ) . entities , <nl> - TextUtilities : : ConvertOption : : SkipLocal ) ; <nl> + if ( isDocument ) { <nl> + const auto document = item - > media ( ) - > document ( ) ; <nl> + if ( ! document ) { <nl> + return ; <nl> + } <nl> <nl> - request ( MTPmessages_EditMessage ( <nl> - MTP_flags ( flagsEditMsg ) , <nl> - item - > history ( ) - > peer - > input , <nl> - MTP_int ( item - > id ) , <nl> - MTP_string ( item - > originalText ( ) . text ) , <nl> - media , <nl> - MTPReplyMarkup ( ) , <nl> - sentEntities <nl> - ) ) . done ( [ = ] ( const MTPUpdates & result ) { <nl> - item - > clearSavedMedia ( ) ; <nl> - item - > setIsLocalUpdateMedia ( true ) ; <nl> - applyUpdates ( result ) ; <nl> - } ) . fail ( [ = ] ( const RPCError & error ) { <nl> - QString err = error . type ( ) ; <nl> - if ( err = = qstr ( " MESSAGE_NOT_MODIFIED " ) <nl> - | | err = = qstr ( " MEDIA_NEW_INVALID " ) ) { <nl> - item - > returnSavedMedia ( ) ; <nl> - _session - > data ( ) . sendHistoryChangeNotifications ( ) ; <nl> - } else { <nl> - sendMessageFail ( error ) ; <nl> - } <nl> - } ) . send ( ) ; <nl> + const auto flags = MTPDinputMediaUploadedDocument : : Flags ( 0 ) <nl> + | ( thumb <nl> + ? MTPDinputMediaUploadedDocument : : Flag : : f_thumb <nl> + : MTPDinputMediaUploadedDocument : : Flag ( 0 ) ) <nl> + / / Never edit video as gif . <nl> + | MTPDinputMediaUploadedDocument : : Flag : : f_nosound_video ; <nl> + media = MTP_inputMediaUploadedDocument ( <nl> + MTP_flags ( flags ) , <nl> + file , <nl> + thumb ? * thumb : MTPInputFile ( ) , <nl> + MTP_string ( document - > mimeString ( ) ) , <nl> + ComposeSendingDocumentAttributes ( document ) , <nl> + MTPVector < MTPInputDocument > ( ) , <nl> + MTP_int ( 0 ) ) ; <nl> + } else { <nl> + const auto photo = item - > media ( ) - > photo ( ) ; <nl> + if ( ! photo ) { <nl> + return ; <nl> } <nl> + media = MTP_inputMediaUploadedPhoto ( <nl> + MTP_flags ( 0 ) , <nl> + file , <nl> + MTPVector < MTPInputDocument > ( ) , <nl> + MTP_int ( 0 ) ) ; <nl> } <nl> + <nl> + request ( MTPmessages_EditMessage ( <nl> + MTP_flags ( flagsEditMsg ) , <nl> + item - > history ( ) - > peer - > input , <nl> + MTP_int ( item - > id ) , <nl> + MTP_string ( item - > originalText ( ) . text ) , <nl> + media , <nl> + MTPReplyMarkup ( ) , <nl> + sentEntities <nl> + ) ) . done ( [ = ] ( const MTPUpdates & result ) { <nl> + item - > clearSavedMedia ( ) ; <nl> + item - > setIsLocalUpdateMedia ( true ) ; <nl> + applyUpdates ( result ) ; <nl> + } ) . fail ( [ = ] ( const RPCError & error ) { <nl> + QString err = error . type ( ) ; <nl> + if ( err = = qstr ( " MESSAGE_NOT_MODIFIED " ) <nl> + | | err = = qstr ( " MEDIA_NEW_INVALID " ) ) { <nl> + item - > returnSavedMedia ( ) ; <nl> + _session - > data ( ) . sendHistoryChangeNotifications ( ) ; <nl> + } else { <nl> + sendMessageFail ( error ) ; <nl> + } <nl> + } ) . send ( ) ; <nl> } <nl> <nl> void ApiWrap : : cancelLocalItem ( not_null < HistoryItem * > item ) { <nl> mmm a / Telegram / SourceFiles / apiwrap . h <nl> ppp b / Telegram / SourceFiles / apiwrap . h <nl> class ApiWrap : public MTP : : Sender , private base : : Subscriber { <nl> const MTPInputFile & file , <nl> const std : : optional < MTPInputFile > & thumb , <nl> bool silent ) ; <nl> - void editUploadedDocument ( <nl> + void editUploadedFile ( <nl> FullMsgId localId , <nl> const MTPInputFile & file , <nl> const std : : optional < MTPInputFile > & thumb , <nl> - bool silent ) ; <nl> - void editUploadedPhoto ( <nl> - FullMsgId localId , <nl> - const MTPInputFile & file , <nl> - bool silent ) ; <nl> + bool silent , <nl> + bool isDocument ) ; <nl> <nl> void cancelLocalItem ( not_null < HistoryItem * > item ) ; <nl> <nl> mmm a / Telegram / SourceFiles / history / history_widget . cpp <nl> ppp b / Telegram / SourceFiles / history / history_widget . cpp <nl> void HistoryWidget : : documentEdited ( <nl> const FullMsgId & newId , <nl> bool silent , <nl> const MTPInputFile & file ) { <nl> - Auth ( ) . api ( ) . editUploadedDocument ( newId , file , std : : nullopt , silent ) ; <nl> + Auth ( ) . api ( ) . editUploadedFile ( newId , file , std : : nullopt , silent , true ) ; <nl> } <nl> <nl> void HistoryWidget : : photoEdited ( <nl> const FullMsgId & newId , <nl> bool silent , <nl> const MTPInputFile & file ) { <nl> - Auth ( ) . api ( ) . editUploadedPhoto ( newId , file , silent ) ; <nl> + Auth ( ) . api ( ) . editUploadedFile ( newId , file , std : : nullopt , silent , false ) ; <nl> } <nl> <nl> void HistoryWidget : : thumbDocumentUploaded ( <nl> void HistoryWidget : : thumbDocumentUploaded ( <nl> const MTPInputFile & thumb , <nl> bool edit ) { <nl> edit <nl> - ? Auth ( ) . api ( ) . editUploadedDocument ( newId , file , thumb , silent ) <nl> + ? Auth ( ) . api ( ) . editUploadedFile ( newId , file , thumb , silent , true ) <nl> : Auth ( ) . api ( ) . sendUploadedDocument ( newId , file , thumb , silent ) ; <nl> } <nl> <nl> | Refactored ApiWrap . | telegramdesktop/tdesktop | bd653dfdffa62f8611b20ab0e6881c18ea141955 | 2019-04-03T17:00:12Z |
mmm a / xbmc / ButtonTranslator . cpp <nl> ppp b / xbmc / ButtonTranslator . cpp <nl> bool CButtonTranslator : : Load ( ) <nl> { <nl> translatorMap . clear ( ) ; <nl> <nl> + / / directories to search for keymaps <nl> + / / they ' re applied in this order , <nl> + / / so keymaps in profile / keymaps / <nl> + / / override e . g . system / keymaps <nl> + static const char * DIRS_TO_CHECK [ ] = { <nl> + " special : / / xbmc / system / keymaps / " , <nl> + " special : / / masterprofile / keymaps / " , <nl> + " special : / / profile / keymaps / " <nl> + } ; <nl> bool success = false ; <nl> - / / Load the config file ( s ) <nl> - / / first from system / keymaps / directory <nl> - const CStdString systemKeymapDirPath = " special : / / xbmc / system / keymaps / " ; <nl> - if ( DIRECTORY : : CDirectory : : Exists ( systemKeymapDirPath ) ) <nl> - { <nl> - CFileItemList files ; <nl> - DIRECTORY : : CDirectory : : GetDirectory ( systemKeymapDirPath , files , " * . xml " ) ; <nl> - / / sort the list for filesystem based prioties , e . g . 01 - keymap . xml , 02 - keymap - overrides . xml <nl> - files . Sort ( SORT_METHOD_FILE , SORT_ORDER_ASC ) ; <nl> - for ( int i = 0 ; i < files . Size ( ) ; + + i ) <nl> - success | = LoadKeymap ( files [ i ] - > m_strPath ) ; <nl> - } <nl> - / / load from user ' s keymaps / directory <nl> - const CStdString userKeymapDirPath = g_settings . GetUserDataItem ( " keymaps / " ) ; <nl> - if ( DIRECTORY : : CDirectory : : Exists ( userKeymapDirPath ) ) <nl> - { <nl> - CFileItemList files ; <nl> - DIRECTORY : : CDirectory : : GetDirectory ( userKeymapDirPath , files , " * . xml " ) ; <nl> - / / sort the list for filesystem based prioties , e . g . 01 - keymap . xml , 02 - keymap - overrides . xml <nl> - files . Sort ( SORT_METHOD_FILE , SORT_ORDER_ASC ) ; <nl> - for ( int i = 0 ; i < files . Size ( ) ; + + i ) <nl> - success | = LoadKeymap ( files [ i ] - > m_strPath ) ; <nl> + <nl> + for ( unsigned int dirIndex = 0 ; dirIndex < sizeof ( DIRS_TO_CHECK ) / sizeof ( DIRS_TO_CHECK [ 0 ] ) ; + + dirIndex ) { <nl> + if ( DIRECTORY : : CDirectory : : Exists ( DIRS_TO_CHECK [ dirIndex ] ) ) <nl> + { <nl> + CFileItemList files ; <nl> + DIRECTORY : : CDirectory : : GetDirectory ( DIRS_TO_CHECK [ dirIndex ] , files , " * . xml " ) ; <nl> + / / sort the list for filesystem based prioties , e . g . 01 - keymap . xml , 02 - keymap - overrides . xml <nl> + files . Sort ( SORT_METHOD_FILE , SORT_ORDER_ASC ) ; <nl> + for ( int fileIndex = 0 ; fileIndex < files . Size ( ) ; + + fileIndex ) <nl> + success | = LoadKeymap ( files [ fileIndex ] - > m_strPath ) ; <nl> + } <nl> } <nl> <nl> / / try to load userdata / Keymap . xml for backward compatibility <nl> bool CButtonTranslator : : Load ( ) <nl> <nl> if ( ! success ) <nl> { <nl> - g_LoadErrorStr . Format ( " Error loading keymaps from : % s or % s " , systemKeymapDirPath . c_str ( ) , userKeymapDirPath . c_str ( ) ) ; <nl> + g_LoadErrorStr . Format ( " Error loading keymaps from : % s or % s or % s " , DIRS_TO_CHECK [ 0 ] , DIRS_TO_CHECK [ 1 ] , DIRS_TO_CHECK [ 2 ] ) ; <nl> return false ; <nl> } <nl> <nl> | fixed : respect profiles for keymap loading ; fixes : | xbmc/xbmc | 78935de63f01efeac8b7020f027d21c296827d9c | 2009-12-07T16:24:38Z |
new file mode 100644 <nl> index 00000000000 . . 1fa6b8b3f8f <nl> mmm / dev / null <nl> ppp b / src / python / interop / interop / _insecure_interop_test . py <nl> <nl> + # Copyright 2015 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + " " " Insecure client - server interoperability as a unit test . " " " <nl> + <nl> + import unittest <nl> + <nl> + from grpc . early_adopter import implementations <nl> + <nl> + from interop import _interop_test_case <nl> + from interop import methods <nl> + <nl> + <nl> + class InsecureInteropTest ( <nl> + _interop_test_case . InteropTestCase , <nl> + unittest . TestCase ) : <nl> + <nl> + def setUp ( self ) : <nl> + self . server = implementations . insecure_server ( methods . SERVER_METHODS , 0 ) <nl> + self . server . start ( ) <nl> + port = self . server . port ( ) <nl> + self . stub = implementations . insecure_stub ( <nl> + methods . CLIENT_METHODS , ' localhost ' , port ) <nl> + <nl> + def tearDown ( self ) : <nl> + self . server . stop ( ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> new file mode 100644 <nl> index 00000000000 . . fec8f1915d5 <nl> mmm / dev / null <nl> ppp b / src / python / interop / interop / _interop_test_case . py <nl> <nl> + # Copyright 2015 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + " " " Common code for unit tests of the interoperability test code . " " " <nl> + <nl> + from interop import methods <nl> + <nl> + <nl> + class InteropTestCase ( object ) : <nl> + " " " Unit test methods . <nl> + <nl> + This class must be mixed in with unittest . TestCase and a class that defines <nl> + setUp and tearDown methods that manage a stub attribute . <nl> + " " " <nl> + <nl> + def testEmptyUnary ( self ) : <nl> + methods . TestCase . EMPTY_UNARY . test_interoperability ( self . stub ) <nl> + <nl> + def testLargeUnary ( self ) : <nl> + methods . TestCase . LARGE_UNARY . test_interoperability ( self . stub ) <nl> + <nl> + def testServerStreaming ( self ) : <nl> + methods . TestCase . SERVER_STREAMING . test_interoperability ( self . stub ) <nl> + <nl> + def testClientStreaming ( self ) : <nl> + methods . TestCase . CLIENT_STREAMING . test_interoperability ( self . stub ) <nl> + <nl> + def testPingPong ( self ) : <nl> + methods . TestCase . PING_PONG . test_interoperability ( self . stub ) <nl> new file mode 100644 <nl> index 00000000000 . . cc9e93821ad <nl> mmm / dev / null <nl> ppp b / src / python / interop / interop / _secure_interop_test . py <nl> <nl> + # Copyright 2015 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + " " " Secure client - server interoperability as a unit test . " " " <nl> + <nl> + import unittest <nl> + <nl> + from grpc . early_adopter import implementations <nl> + <nl> + from interop import _interop_test_case <nl> + from interop import methods <nl> + from interop import resources <nl> + <nl> + _SERVER_HOST_OVERRIDE = ' foo . test . google . fr ' <nl> + <nl> + <nl> + class SecureInteropTest ( <nl> + _interop_test_case . InteropTestCase , <nl> + unittest . TestCase ) : <nl> + <nl> + def setUp ( self ) : <nl> + self . server = implementations . secure_server ( <nl> + methods . SERVER_METHODS , 0 , resources . private_key ( ) , <nl> + resources . certificate_chain ( ) ) <nl> + self . server . start ( ) <nl> + port = self . server . port ( ) <nl> + self . stub = implementations . secure_stub ( <nl> + methods . CLIENT_METHODS , ' localhost ' , port , <nl> + resources . test_root_certificates ( ) , None , None , <nl> + server_host_override = _SERVER_HOST_OVERRIDE ) <nl> + <nl> + def tearDown ( self ) : <nl> + self . server . stop ( ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> mmm a / src / python / interop / interop / client . py <nl> ppp b / src / python / interop / interop / client . py <nl> def _stub ( args ) : <nl> root_certificates = resources . test_root_certificates ( ) <nl> else : <nl> root_certificates = resources . prod_root_certificates ( ) <nl> - # TODO ( nathaniel ) : server host override . <nl> <nl> stub = implementations . secure_stub ( <nl> methods . CLIENT_METHODS , args . server_host , args . server_port , <nl> - root_certificates , None , None ) <nl> + root_certificates , None , None , <nl> + server_host_override = args . server_host_override ) <nl> else : <nl> stub = implementations . insecure_stub ( <nl> methods . CLIENT_METHODS , args . server_host , args . server_port ) <nl> return stub <nl> <nl> <nl> + def _test_case_from_arg ( test_case_arg ) : <nl> + for test_case in methods . TestCase : <nl> + if test_case_arg = = test_case . value : <nl> + return test_case <nl> + else : <nl> + raise ValueError ( ' No test case " % s " ! ' % test_case_arg ) <nl> + <nl> + <nl> def _test_interoperability ( ) : <nl> args = _args ( ) <nl> stub = _stub ( args ) <nl> - methods . test_interoperability ( args . test_case , stub ) <nl> + test_case = _test_case_from_arg ( args . test_case ) <nl> + test_case . test_interoperability ( stub ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / src / python / interop / interop / methods . py <nl> ppp b / src / python / interop / interop / methods . py <nl> <nl> <nl> " " " Implementations of interoperability test methods . " " " <nl> <nl> + import enum <nl> import threading <nl> <nl> from grpc . early_adopter import utilities <nl> def _ping_pong ( stub ) : <nl> pipe . close ( ) <nl> <nl> <nl> - def test_interoperability ( test_case , stub ) : <nl> - if test_case = = ' empty_unary ' : <nl> - _empty_unary ( stub ) <nl> - elif test_case = = ' large_unary ' : <nl> - _large_unary ( stub ) <nl> - elif test_case = = ' server_streaming ' : <nl> - _server_streaming ( stub ) <nl> - elif test_case = = ' client_streaming ' : <nl> - _client_streaming ( stub ) <nl> - elif test_case = = ' ping_pong ' : <nl> - _ping_pong ( stub ) <nl> - else : <nl> - raise NotImplementedError ( ' Test case " % s " not implemented ! ' ) <nl> + @ enum . unique <nl> + class TestCase ( enum . Enum ) : <nl> + EMPTY_UNARY = ' empty_unary ' <nl> + LARGE_UNARY = ' large_unary ' <nl> + SERVER_STREAMING = ' server_streaming ' <nl> + CLIENT_STREAMING = ' client_streaming ' <nl> + PING_PONG = ' ping_pong ' <nl> + <nl> + def test_interoperability ( self , stub ) : <nl> + if self is TestCase . EMPTY_UNARY : <nl> + _empty_unary ( stub ) <nl> + elif self is TestCase . LARGE_UNARY : <nl> + _large_unary ( stub ) <nl> + elif self is TestCase . SERVER_STREAMING : <nl> + _server_streaming ( stub ) <nl> + elif self is TestCase . CLIENT_STREAMING : <nl> + _client_streaming ( stub ) <nl> + elif self is TestCase . PING_PONG : <nl> + _ping_pong ( stub ) <nl> + else : <nl> + raise NotImplementedError ( ' Test case " % s " not implemented ! ' % self . name ) <nl> mmm a / src / python / src / grpc / _adapter / _c_test . py <nl> ppp b / src / python / src / grpc / _adapter / _c_test . py <nl> def testCompletionQueue ( self ) : <nl> def testChannel ( self ) : <nl> _c . init ( ) <nl> <nl> - channel = _c . Channel ( ' test host : 12345 ' , None ) <nl> + channel = _c . Channel ( <nl> + ' test host : 12345 ' , None , server_host_override = ' ignored ' ) <nl> del channel <nl> <nl> _c . shut_down ( ) <nl> mmm a / src / python / src / grpc / _adapter / _channel . c <nl> ppp b / src / python / src / grpc / _adapter / _channel . c <nl> <nl> static int pygrpc_channel_init ( Channel * self , PyObject * args , PyObject * kwds ) { <nl> const char * hostport ; <nl> PyObject * client_credentials ; <nl> - static char * kwlist [ ] = { " hostport " , " client_credentials " , NULL } ; <nl> + char * server_host_override = NULL ; <nl> + static char * kwlist [ ] = { " hostport " , " client_credentials " , <nl> + " server_host_override " , NULL } ; <nl> + grpc_arg server_host_override_arg ; <nl> + grpc_channel_args channel_args ; <nl> <nl> - if ( ! ( PyArg_ParseTupleAndKeywords ( args , kwds , " sO : Channel " , kwlist , <nl> - & hostport , & client_credentials ) ) ) { <nl> + if ( ! ( PyArg_ParseTupleAndKeywords ( args , kwds , " sO | z : Channel " , kwlist , <nl> + & hostport , & client_credentials , <nl> + & server_host_override ) ) ) { <nl> return - 1 ; <nl> } <nl> if ( client_credentials = = Py_None ) { <nl> self - > c_channel = grpc_channel_create ( hostport , NULL ) ; <nl> return 0 ; <nl> } else { <nl> - self - > c_channel = grpc_secure_channel_create ( <nl> - ( ( ClientCredentials * ) client_credentials ) - > c_client_credentials , <nl> - hostport , NULL ) ; <nl> + if ( server_host_override = = NULL ) { <nl> + self - > c_channel = grpc_secure_channel_create ( <nl> + ( ( ClientCredentials * ) client_credentials ) - > c_client_credentials , <nl> + hostport , NULL ) ; <nl> + } else { <nl> + server_host_override_arg . type = GRPC_ARG_STRING ; <nl> + server_host_override_arg . key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG ; <nl> + server_host_override_arg . value . string = server_host_override ; <nl> + channel_args . num_args = 1 ; <nl> + channel_args . args = & server_host_override_arg ; <nl> + self - > c_channel = grpc_secure_channel_create ( <nl> + ( ( ClientCredentials * ) client_credentials ) - > c_client_credentials , <nl> + hostport , & channel_args ) ; <nl> + } <nl> return 0 ; <nl> } <nl> } <nl> mmm a / src / python / src / grpc / _adapter / rear . py <nl> ppp b / src / python / src / grpc / _adapter / rear . py <nl> class RearLink ( ticket_interfaces . RearLink , activated . Activated ) : <nl> <nl> def __init__ ( <nl> self , host , port , pool , request_serializers , response_deserializers , <nl> - secure , root_certificates , private_key , certificate_chain ) : <nl> + secure , root_certificates , private_key , certificate_chain , <nl> + server_host_override = None ) : <nl> " " " Constructor . <nl> <nl> Args : <nl> def __init__ ( <nl> key should be used . <nl> certificate_chain : The PEM - encoded certificate chain to use or None if <nl> no certificate chain should be used . <nl> + server_host_override : ( For testing only ) the target name used for SSL <nl> + host name checking . <nl> " " " <nl> self . _condition = threading . Condition ( ) <nl> self . _host = host <nl> def __init__ ( <nl> self . _root_certificates = root_certificates <nl> self . _private_key = private_key <nl> self . _certificate_chain = certificate_chain <nl> + self . _server_host_override = server_host_override <nl> <nl> def _on_write_event ( self , operation_id , event , rpc_state ) : <nl> if event . write_accepted : <nl> def _start ( self ) : <nl> with self . _condition : <nl> self . _completion_queue = _low . CompletionQueue ( ) <nl> self . _channel = _low . Channel ( <nl> - ' % s : % d ' % ( self . _host , self . _port ) , self . _client_credentials ) <nl> + ' % s : % d ' % ( self . _host , self . _port ) , self . _client_credentials , <nl> + server_host_override = self . _server_host_override ) <nl> return self <nl> <nl> def _stop ( self ) : <nl> class _ActivatedRearLink ( ticket_interfaces . RearLink , activated . Activated ) : <nl> <nl> def __init__ ( <nl> self , host , port , request_serializers , response_deserializers , secure , <nl> - root_certificates , private_key , certificate_chain ) : <nl> + root_certificates , private_key , certificate_chain , <nl> + server_host_override = None ) : <nl> self . _host = host <nl> self . _port = port <nl> self . _request_serializers = request_serializers <nl> def __init__ ( <nl> self . _root_certificates = root_certificates <nl> self . _private_key = private_key <nl> self . _certificate_chain = certificate_chain <nl> + self . _server_host_override = server_host_override <nl> <nl> self . _lock = threading . Lock ( ) <nl> self . _pool = None <nl> def _start ( self ) : <nl> self . _rear_link = RearLink ( <nl> self . _host , self . _port , self . _pool , self . _request_serializers , <nl> self . _response_deserializers , self . _secure , self . _root_certificates , <nl> - self . _private_key , self . _certificate_chain ) <nl> + self . _private_key , self . _certificate_chain , <nl> + server_host_override = self . _server_host_override ) <nl> self . _rear_link . join_fore_link ( self . _fore_link ) <nl> self . _rear_link . start ( ) <nl> return self <nl> def activated_rear_link ( <nl> <nl> def secure_activated_rear_link ( <nl> host , port , request_serializers , response_deserializers , root_certificates , <nl> - private_key , certificate_chain ) : <nl> + private_key , certificate_chain , server_host_override = None ) : <nl> " " " Creates a RearLink that is also an activated . Activated . <nl> <nl> The returned object is only valid for use between calls to its start and stop <nl> def secure_activated_rear_link ( <nl> should be used . <nl> certificate_chain : The PEM - encoded certificate chain to use or None if no <nl> certificate chain should be used . <nl> + server_host_override : ( For testing only ) the target name used for SSL <nl> + host name checking . <nl> " " " <nl> return _ActivatedRearLink ( <nl> host , port , request_serializers , response_deserializers , True , <nl> - root_certificates , private_key , certificate_chain ) <nl> + root_certificates , private_key , certificate_chain , <nl> + server_host_override = server_host_override ) <nl> mmm a / src / python / src / grpc / early_adopter / implementations . py <nl> ppp b / src / python / src / grpc / early_adopter / implementations . py <nl> def insecure_stub ( methods , host , port ) : <nl> <nl> <nl> def secure_stub ( <nl> - methods , host , port , root_certificates , private_key , certificate_chain ) : <nl> + methods , host , port , root_certificates , private_key , certificate_chain , <nl> + server_host_override = None ) : <nl> " " " Constructs an insecure interfaces . Stub . <nl> <nl> Args : <nl> def secure_stub ( <nl> should be used . <nl> certificate_chain : The PEM - encoded certificate chain to use or None if no <nl> certificate chain should be used . <nl> + server_host_override : ( For testing only ) the target name used for SSL <nl> + host name checking . <nl> <nl> Returns : <nl> An interfaces . Stub affording RPC invocation . <nl> def secure_stub ( <nl> activated_rear_link = _rear . secure_activated_rear_link ( <nl> host , port , breakdown . request_serializers , <nl> breakdown . response_deserializers , root_certificates , private_key , <nl> - certificate_chain ) <nl> + certificate_chain , server_host_override = server_host_override ) <nl> return _build_stub ( breakdown , activated_rear_link ) <nl> <nl> <nl> mmm a / tools / run_tests / build_python . sh <nl> ppp b / tools / run_tests / build_python . sh <nl> virtualenv - p / usr / bin / python2 . 7 python2 . 7_virtual_environment <nl> source python2 . 7_virtual_environment / bin / activate <nl> pip install enum34 = = 1 . 0 . 4 futures = = 2 . 2 . 0 protobuf = = 3 . 0 . 0 - alpha - 1 <nl> CFLAGS = - I $ root / include LDFLAGS = - L $ root / libs / opt pip install src / python / src <nl> + pip install src / python / interop <nl> mmm a / tools / run_tests / python_tests . json <nl> ppp b / tools / run_tests / python_tests . json <nl> <nl> } , <nl> { <nl> " module " : " grpc . framework . foundation . _logging_pool_test " <nl> + } , <nl> + { <nl> + " module " : " interop . _insecure_interop_test " <nl> + } , <nl> + { <nl> + " module " : " interop . _secure_interop_test " <nl> } <nl> ] <nl> | Merge pull request from nathanielmanistaatgoogle / interop | grpc/grpc | 3aca2a624523e8bb27891d759b6fbbe71277be3d | 2015-03-07T01:02:52Z |
mmm a / xbmc / GUIInfoManager . cpp <nl> ppp b / xbmc / GUIInfoManager . cpp <nl> const infomap retroplayer [ ] = <nl> / / / \ subsection modules__infolabels_boolean_conditions_Container Container <nl> / / / \ table_start <nl> / / / \ table_h3 { Labels , Type , Description } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . HasFiles ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . HasFiles ` < / b > , <nl> / / / \ anchor Container_HasFiles <nl> / / / _boolean_ , <nl> - / / / @ return * * True * * if the container contains files ( or current container if <nl> - / / / id is omitted ) . <nl> + / / / @ return * * True * * if the container contains files . <nl> / / / < p > <nl> / / / } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . HasFolders ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . HasFolders ` < / b > , <nl> / / / \ anchor Container_HasFolders <nl> / / / _boolean_ , <nl> - / / / @ return * * True * * if the container contains folders ( or current container if <nl> - / / / id is omitted ) . <nl> + / / / @ return * * True * * if the container contains folders . <nl> / / / < p > <nl> / / / } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . IsStacked ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . IsStacked ` < / b > , <nl> / / / \ anchor Container_IsStacked <nl> / / / _boolean_ , <nl> - / / / @ return * * True * * if the container is currently in stacked mode ( or current <nl> - / / / container if id is omitted ) . <nl> + / / / @ return * * True * * if the container is currently in stacked mode . <nl> / / / < p > <nl> / / / } <nl> / / / \ table_row3 { < b > ` Container . FolderPath ` < / b > , <nl> const infomap retroplayer [ ] = <nl> / / / @ skinning_v17 * * [ New Infolabel ] * * \ link Container_ViewCount ` Container . ViewCount ` \ endlink <nl> / / / < p > <nl> / / / } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . Totaltime ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . Totaltime ` < / b > , <nl> / / / \ anchor Container_Totaltime <nl> / / / _string_ , <nl> / / / @ return The total time of all items in the current container . <nl> / / / < p > <nl> / / / } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . TotalWatched ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . TotalWatched ` < / b > , <nl> / / / \ anchor Container_TotalWatched <nl> / / / _string_ , <nl> / / / @ return The number of watched items in the container . <nl> const infomap retroplayer [ ] = <nl> / / / @ skinning_v16 * * [ New Infolabel ] * * \ link Container_TotalWatched ` Container ( id ) . TotalWatched ` \ endlink <nl> / / / < p > <nl> / / / } <nl> - / / / \ table_row3 { < b > ` Container ( id ) . TotalUnWatched ` < / b > , <nl> + / / / \ table_row3 { < b > ` Container . TotalUnWatched ` < / b > , <nl> / / / \ anchor Container_TotalUnWatched <nl> / / / _string_ , <nl> / / / @ return The number of unwatched items in the container . <nl> | fix documentation for infolabels that don ' t support ( id ) | xbmc/xbmc | 34d6177b8e6e9169c1d79248cc1f998a1fc9c256 | 2020-04-14T10:47:09Z |
mmm a / Telegram / lib_spellcheck <nl> ppp b / Telegram / lib_spellcheck <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 195c2b81d1b9730f15d1e1c14cf1dd1976b9e1f1 <nl> + Subproject commit 691cda5b223133396a53246c14f613ff04542628 <nl> | Beta version 1 . 9 . 10 : Update lib_spellcheck . | telegramdesktop/tdesktop | cc71bdce8f5a26bc1228425bb84e595772d457b2 | 2020-02-05T16:33:46Z |
mmm a / xbmc / addons / AddonManager . cpp <nl> ppp b / xbmc / addons / AddonManager . cpp <nl> void CAddonMgr : : FindAddons ( ) <nl> CSingleLock lock ( m_critSection ) ; <nl> m_addons . clear ( ) ; <nl> m_idMap . clear ( ) ; <nl> - LoadAddons ( " special : / / home / addons " ) ; <nl> + if ( ! CSpecialProtocol : : XBMCIsHome ( ) ) <nl> + LoadAddons ( " special : / / home / addons " ) ; <nl> LoadAddons ( " special : / / xbmc / addons " ) ; <nl> } <nl> <nl> | fixed : don ' t check special : / / xbmc / addons twice when running with - p | xbmc/xbmc | 28831ed16dbb0b83b2f3c64a016ffda41cc8a50d | 2010-04-27T15:15:15Z |
mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> py_library ( <nl> ] , <nl> ) <nl> <nl> + py_library ( <nl> + name = " loss_scale " , <nl> + srcs = [ " training / loss_scale . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " / / tensorflow / python : framework " , <nl> + " : keras_lib " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " loss_scale_optimizer " , <nl> + srcs = [ " training / loss_scale_optimizer . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : loss_scale " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> + py_test ( <nl> + name = " loss_scale_optimizer_test " , <nl> + size = " small " , <nl> + srcs = [ " training / loss_scale_optimizer_test . py " ] , <nl> + deps = [ <nl> + " : loss_scale_optimizer " , <nl> + " / / tensorflow / python / keras / mixed_precision / experimental : test_util " , <nl> + " / / tensorflow / python : client_testlib " , <nl> + " / / tensorflow / python / distribute : mirrored_strategy " , <nl> + " / / tensorflow / python / distribute : one_device_strategy " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> + py_test ( <nl> + name = " loss_scale_test " , <nl> + size = " small " , <nl> + srcs = [ " training / loss_scale_test . py " ] , <nl> + deps = [ <nl> + " : loss_scale " , <nl> + " / / tensorflow / python : client_testlib " , <nl> + " / / tensorflow / python / distribute : mirrored_strategy " , <nl> + " / / tensorflow / python / distribute : one_device_strategy " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> py_library ( <nl> name = " math_grad " , <nl> srcs = [ " ops / math_grad . py " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . 94265e4974a98 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / training / loss_scale . py <nl> <nl> + # Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Contains LossScaler classes . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import abc <nl> + import six <nl> + <nl> + from tensorflow . python . framework import dtypes <nl> + from tensorflow . python . framework import ops <nl> + from tensorflow . python . keras import initializers <nl> + from tensorflow . python . keras . engine import base_layer_utils <nl> + from tensorflow . python . ops import control_flow_ops <nl> + from tensorflow . python . ops import variables <nl> + from tensorflow . python . training . tracking import base as trackable <nl> + from tensorflow . python . ops import math_ops <nl> + from tensorflow . python . distribute import distribution_strategy_context <nl> + from tensorflow . python . distribute import reduce_util <nl> + from tensorflow . python . eager import context <nl> + from tensorflow . python . util . tf_export import tf_export <nl> + <nl> + <nl> + @ six . add_metaclass ( abc . ABCMeta ) <nl> + @ tf_export ( v1 = [ ' train . LossScale ' ] ) <nl> + class LossScale ( trackable . Trackable ) : <nl> + " " " Base class to compute the loss scale . <nl> + <nl> + Loss scaling is a process that : <nl> + <nl> + 1 ) Applies a multiplier on the loss before computing gradients , and <nl> + 2 ) Applies the reciprocal of the multiplier on the gradients before they are <nl> + applied on variables . <nl> + <nl> + Mathematically , loss scaling has no effect , but can help avoid numerical <nl> + underflow when float16 tensors are used . By multiplying the loss , each <nl> + gradient will have the same multiplier applied . <nl> + <nl> + Instances of this class compute the loss scale . Method ` get_loss_scale ( ) ` <nl> + returns the current loss scale , while method ` update ( ) ` updates the loss scale <nl> + depending on the values of the gradients . Optimizers use instances of this <nl> + class to scale loss and gradients . <nl> + " " " <nl> + <nl> + def __init__ ( self ) : <nl> + " " " Initializes the loss scale class . <nl> + <nl> + Note subclasses should create variables in build ( ) instead of in the <nl> + constructor . This is because callers might choose to place variables on <nl> + a certain device by calling build ( ) under a tf . device ( ) scope . <nl> + " " " <nl> + self . built = False <nl> + self . _weights = { } <nl> + <nl> + def build ( self ) : <nl> + " " " Builds the weights of the loss scale class . <nl> + <nl> + If weights are needed , subclasses should build weights by calling <nl> + ` self . add_weight ( . . . ) ` , then call the super ' s build to set self . built = <nl> + True . <nl> + " " " <nl> + self . built = True <nl> + <nl> + def __call__ ( self ) : <nl> + " " " Returns the current loss scale as a scalar ` float32 ` tensor . " " " <nl> + if not self . built : <nl> + self . build ( ) <nl> + return self . _get_loss_scale ( ) <nl> + <nl> + @ abc . abstractmethod <nl> + def _get_loss_scale ( self ) : <nl> + " " " Returns the loss scale without calling build ( ) . <nl> + <nl> + Subclasses must implement this . Subclasses should not override the public <nl> + ` __call__ ` method , which calls this method . <nl> + " " " <nl> + pass <nl> + <nl> + def update ( self , grads ) : <nl> + " " " Updates the value of the loss scale . <nl> + <nl> + The loss scale tensor will be potentially updated , based on the value of <nl> + ` grads ` . The tensor returned by ` get_loss_scale ` is only <nl> + updated when this function is evaluated . <nl> + <nl> + In eager mode , this directly updates the loss scale , so that calling <nl> + ` get_loss_scale ` will return the newly updated loss scale . In graph mode , <nl> + this returns an op that , when evaluated , updates the loss scale . <nl> + <nl> + This function also returns a ` should_apply_gradients ` bool . If False , <nl> + gradients should not be applied to the variables that step , as nonfinite <nl> + gradients were found , and the loss scale controller can update the loss <nl> + scale to reduce the chance of finding nonfinite gradients in the next step . <nl> + Some loss scale controllers will always return True , as they cannot adjust <nl> + the loss scale in response to nonfinite gradients . <nl> + <nl> + When a DistributionStrategy is used , this function may only be called in a <nl> + cross - replica context . <nl> + <nl> + Args : <nl> + grads : A list of unscaled gradients , each which is the gradient of the <nl> + loss with respect to a weight . The gradients should have already been <nl> + divided by the loss scale being before passed to this function . <nl> + <nl> + Returns : <nl> + update_op : In eager mode , None . In graph mode , an op to update the loss <nl> + scale . <nl> + should_apply_gradients : Either a bool or a scalar boolean tensor . If <nl> + False , the caller should skip applying ` grads ` to the variables this <nl> + step . <nl> + " " " <nl> + if not self . built : <nl> + self . build ( ) <nl> + return self . _update ( grads ) <nl> + <nl> + @ abc . abstractmethod <nl> + def _update ( self , grads ) : <nl> + " " " Updates the value of the loss scale without calling build ( ) . <nl> + <nl> + Subclasses must implement this . Subclasses should not override the public <nl> + ` update_loss_scale ` method , which calls this method . <nl> + <nl> + Args : <nl> + grads : A list of unscaled gradients . See ` update_loss_scale ` . <nl> + <nl> + Returns : <nl> + In eager mode , None . In graph mode , an op to update the loss scale . <nl> + " " " <nl> + pass <nl> + <nl> + <nl> + def add_weight ( self , <nl> + name , <nl> + shape = ( ) , <nl> + dtype = None , <nl> + initializer = ' zeros ' ) : <nl> + " " " Adds a weight to this loss scale manager . . <nl> + <nl> + This should be called by subclasses in ` build ( ) ` to build the weights of the <nl> + loss scale class . <nl> + <nl> + Args : <nl> + name : Variable name . <nl> + shape : Variable shape . <nl> + dtype : The type of the variable . <nl> + initializer : The initializer to use . <nl> + <nl> + Returns : <nl> + A variable . <nl> + " " " <nl> + if isinstance ( initializer , six . string_types ) or callable ( initializer ) : <nl> + initializer = initializers . get ( initializer ) <nl> + variable = self . _add_variable_with_custom_getter ( <nl> + name = name , <nl> + shape = shape , <nl> + getter = base_layer_utils . make_variable , <nl> + overwrite = True , <nl> + initializer = initializer , <nl> + dtype = dtype , <nl> + trainable = False , <nl> + use_resource = True , <nl> + synchronization = variables . VariableSynchronization . AUTO , <nl> + # Set aggregation to NONE , as loss scaling variables should never be <nl> + # aggregated . <nl> + aggregation = variables . VariableAggregation . NONE ) <nl> + if context . executing_eagerly ( ) : <nl> + graph_key = None <nl> + else : <nl> + graph = ops . get_default_graph ( ) <nl> + graph_key = graph . _graph_key # pylint : disable = protected - access <nl> + <nl> + key = ( graph_key , name ) <nl> + if self . _weights . get ( key , None ) is not None : <nl> + raise RuntimeError ( ' Duplicate variables detected . { } ' . format ( key ) ) <nl> + self . _weights [ key ] = variable <nl> + self . _handle_deferred_dependencies ( name = name , trackable = variable ) <nl> + return variable <nl> + <nl> + @ property <nl> + def _checkpoint_dependencies ( self ) : <nl> + " " " From Trackable . Gather graph - specific weights to save . " " " <nl> + if context . executing_eagerly ( ) : <nl> + graph_key = None <nl> + else : <nl> + graph = ops . get_default_graph ( ) <nl> + graph_key = graph . _graph_key # pylint : disable = protected - access <nl> + weights = [ trackable . TrackableReference ( name = name , ref = v ) <nl> + for ( g , name ) , v in sorted ( <nl> + self . _weights . items ( ) , key = lambda i : i [ 0 ] [ 1 ] ) <nl> + if g = = graph_key ] <nl> + return super ( LossScale , self ) . _checkpoint_dependencies + weights <nl> + <nl> + def _lookup_dependency ( self , name ) : <nl> + " " " From Trackable . Find a weight in the current graph . " " " <nl> + unconditional = super ( LossScale , self ) . _lookup_dependency ( name ) <nl> + if unconditional is not None : <nl> + return unconditional <nl> + if context . executing_eagerly ( ) : <nl> + graph_key = None <nl> + else : <nl> + graph = ops . get_default_graph ( ) <nl> + graph_key = graph . _graph_key # pylint : disable = protected - access <nl> + return self . _weights . get ( ( graph_key , name ) , None ) <nl> + <nl> + @ tf_export ( v1 = [ ' train . FixedLossScale ' ] ) <nl> + class FixedLossScale ( LossScale ) : <nl> + " " " Loss scale class with a fixed value . <nl> + <nl> + The loss scale is not updated for the lifetime of the class . <nl> + " " " <nl> + <nl> + def __init__ ( self , loss_scale_value ) : <nl> + " " " Creates the fixed loss scale . <nl> + <nl> + Args : <nl> + loss_scale : A Python float . Its ideal value varies depending on models to <nl> + run . Choosing a too small loss_scale might affect model quality ; a too <nl> + big loss_scale might cause inf or nan . There is no single right <nl> + loss_scale to apply . There is no harm choosing a relatively big number <nl> + as long as no nan or inf is encountered in training . <nl> + <nl> + Raises : <nl> + ValueError : If loss_scale is less than 1 . <nl> + " " " <nl> + super ( FixedLossScale , self ) . __init__ ( ) <nl> + if not isinstance ( loss_scale_value , six . integer_types + ( float , ) ) : <nl> + raise ValueError ( ' loss_scale must be a Python int or float . ' ) <nl> + if loss_scale_value < 1 : <nl> + raise ValueError ( ' loss scale must be at least 1 . ' ) <nl> + self . _tensor_loss_scale = ops . convert_to_tensor ( loss_scale_value , <nl> + dtype = dtypes . float32 ) <nl> + <nl> + def _get_loss_scale ( self ) : <nl> + return self . _tensor_loss_scale <nl> + <nl> + def _update ( self , grads ) : <nl> + del grads <nl> + return control_flow_ops . no_op ( ) , True <nl> + <nl> + <nl> + def _is_all_finite ( grads ) : <nl> + " " " Returns a scalar boolean tensor indicating if all gradients are finite . " " " <nl> + is_finite_per_grad = [ math_ops . reduce_all ( math_ops . is_finite ( g ) ) <nl> + for g in grads ] <nl> + return math_ops . reduce_all ( is_finite_per_grad ) <nl> + <nl> + <nl> + def _op_in_graph_mode ( tensor ) : <nl> + " " " Returns the tensor ' s op in graph mode , or the tensor in eager mode . <nl> + <nl> + This is useful because sometimes an op is needed in graph mode instead of a <nl> + tensor . In eager mode , there are no ops . <nl> + <nl> + Args : <nl> + tensor : A tensor . <nl> + <nl> + Returns : <nl> + The tensor ' s op in graph mode . The tensor in eager mode . <nl> + " " " <nl> + if context . executing_eagerly ( ) : <nl> + return tensor <nl> + return tensor . op <nl> + <nl> + <nl> + def _assign_if_finite ( var , value ) : <nl> + " " " Assigns a value to a variable if the value is finite . " " " <nl> + return control_flow_ops . cond ( <nl> + math_ops . is_finite ( value ) , <nl> + lambda : _op_in_graph_mode ( var . assign ( value ) ) , <nl> + control_flow_ops . no_op ) <nl> + <nl> + <nl> + @ tf_export ( v1 = [ ' train . DynamicLossScale ' ] ) <nl> + class DynamicLossScale ( LossScale ) : <nl> + " " " Loss scale class that dynamically adjusts the loss scale . <nl> + <nl> + Dynamic loss scaling works by adjusting the loss scale as training progresses . <nl> + The goal is to keep the loss scale as high as possible without overflowing the <nl> + gradients . As long as the gradients do not overflow , raising the loss scale <nl> + never hurts . <nl> + <nl> + The algorithm starts by setting the loss scale to an initial value . Every N <nl> + steps that the gradients are finite , the loss scale is increased by some <nl> + factor . However , if a NaN or Inf gradient is found , the gradients for that <nl> + step are not applied , and the loss scale is decreased by the factor . This <nl> + process tends to keep the loss scale as high as possible without gradients <nl> + overflowing . <nl> + " " " <nl> + <nl> + def __init__ ( self , <nl> + initial_loss_scale = 2 * * 15 , <nl> + increment_period = 2000 , <nl> + multiplier = 2 . ) : <nl> + " " " Constructor of exponential - update loss scale class . <nl> + <nl> + Args : <nl> + initial_loss_scale : A Python float . The loss scale to use at the <nl> + beginning . It ' s better to start this at a very high number , because a <nl> + loss scale that is too high gets lowered far more quickly than a loss <nl> + scale that is to low gets raised . The default is 2 * * 15 , which is <nl> + approximately half the maximum float16 value . <nl> + incr_every_n_steps : Increases loss scale every ` incr_every_n_steps ` <nl> + consecutive steps that finite gradients are encountered . If a nonfinite <nl> + gradient is encountered , the count is reset back to zero . <nl> + loss_scale_multiplier : The multiplier to use when increasing or decreasing <nl> + the loss scale . <nl> + " " " <nl> + super ( DynamicLossScale , self ) . __init__ ( ) <nl> + self . _initial_loss_scale = float ( initial_loss_scale ) <nl> + self . _increment_period = int ( increment_period ) <nl> + self . _multiplier = float ( multiplier ) <nl> + <nl> + <nl> + @ property <nl> + def initial_loss_scale ( self ) : <nl> + return self . _initial_loss_scale <nl> + <nl> + @ property <nl> + def increment_period ( self ) : <nl> + return self . _increment_period <nl> + <nl> + @ property <nl> + def multiplier ( self ) : <nl> + return self . _multiplier <nl> + <nl> + def build ( self ) : <nl> + self . _current_loss_scale = self . add_weight ( <nl> + name = ' loss_scale ' , <nl> + dtype = dtypes . float32 , <nl> + initializer = self . _initial_loss_scale ) <nl> + self . _num_good_steps = self . add_weight ( <nl> + name = ' good_steps ' , dtype = dtypes . int64 , initializer = ' zeros ' ) <nl> + self . built = True <nl> + <nl> + def _get_loss_scale ( self ) : <nl> + return self . _current_loss_scale <nl> + <nl> + def _update ( self , grads ) : <nl> + " " " Updates loss scale based on if gradients are finite in current step . " " " <nl> + if distribution_strategy_context . has_strategy ( ) : <nl> + distribution = distribution_strategy_context . get_cross_replica_context ( ) <nl> + def get_is_finite ( grads ) : <nl> + is_finite = _is_all_finite ( grads ) <nl> + # We cast to float , because we cannot reduce booleans with <nl> + # DistributionStrategy . <nl> + return math_ops . cast ( is_finite , dtypes . float32 ) <nl> + is_finite_float = distribution . extended . call_for_each_replica ( <nl> + get_is_finite , args = ( grads , ) ) <nl> + reduced_is_finite_float = distribution . reduce ( reduce_util . ReduceOp . SUM , <nl> + is_finite_float ) <nl> + is_finite = math_ops . equal ( reduced_is_finite_float , <nl> + distribution . num_replicas_in_sync ) <nl> + else : <nl> + is_finite = _is_all_finite ( grads ) <nl> + <nl> + def update_if_finite_grads ( ) : <nl> + " " " Update assuming the gradients are finite . " " " <nl> + <nl> + def incr_loss_scale ( ) : <nl> + new_loss_scale = self . _current_loss_scale * self . _multiplier <nl> + return control_flow_ops . group ( <nl> + _assign_if_finite ( self . _current_loss_scale , new_loss_scale ) , <nl> + self . _num_good_steps . assign ( 0 ) ) <nl> + <nl> + return control_flow_ops . cond ( <nl> + self . _num_good_steps + 1 > = self . _increment_period , <nl> + incr_loss_scale , <nl> + lambda : _op_in_graph_mode ( self . _num_good_steps . assign_add ( 1 ) ) ) <nl> + <nl> + def update_if_not_finite_grads ( ) : <nl> + " " " Update assuming the gradients are nonfinite . " " " <nl> + <nl> + new_loss_scale = math_ops . maximum ( <nl> + self . _current_loss_scale / self . _multiplier , 1 ) <nl> + return control_flow_ops . group ( <nl> + self . _num_good_steps . assign ( 0 ) , <nl> + self . _current_loss_scale . assign ( new_loss_scale ) <nl> + ) <nl> + <nl> + <nl> + update_op = control_flow_ops . cond ( is_finite , update_if_finite_grads , <nl> + update_if_not_finite_grads ) <nl> + should_apply_gradients = is_finite <nl> + return update_op , should_apply_gradients <nl> + <nl> + <nl> + def get ( identifier ) : <nl> + " " " Get a loss scale object . " " " <nl> + if isinstance ( identifier , six . integer_types + ( float , ) ) : <nl> + return FixedLossScale ( identifier ) <nl> + if identifier = = ' dynamic ' : <nl> + return DynamicLossScale ( ) <nl> + if isinstance ( identifier , LossScale ) : <nl> + return identifier <nl> + elif identifier is None : <nl> + return None <nl> + else : <nl> + raise ValueError ( ' Could not interpret loss scale identifier : % s ' <nl> + % identifier ) <nl> new file mode 100644 <nl> index 0000000000000 . . d70e19d8b5bbb <nl> mmm / dev / null <nl> ppp b / tensorflow / python / training / loss_scale_optimizer . py <nl> <nl> + # Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Contains LossScale classes . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + from tensorflow . python . framework import ops <nl> + from tensorflow . python . framework import smart_cond <nl> + from tensorflow . python . ops import control_flow_ops <nl> + from tensorflow . python . training import loss_scale as loss_scale_module <nl> + from tensorflow . python . training import optimizer <nl> + from tensorflow . python . distribute import distribution_strategy_context <nl> + from tensorflow . python . util . tf_export import tf_export <nl> + <nl> + <nl> + @ tf_export ( v1 = [ ' train . LossScaleOptimizer ' ] ) <nl> + class LossScaleOptimizer ( optimizer . Optimizer ) : <nl> + " " " An optimizer that applies loss scaling . <nl> + <nl> + The loss scale can either be a fixed constant , chosen by the user , or be <nl> + dynamically determined . Dynamically determining the loss scale is convenient <nl> + as a loss scale does not have to be explicitly chosen . However it reduces <nl> + performance . <nl> + <nl> + This optimizer wraps another optimizer and applies loss scaling to it . Loss <nl> + scaling is applied whenever gradients are computed . <nl> + <nl> + Args : <nl> + opt : The Optimizer instance to wrap . <nl> + loss_scale : The loss scale or LossScale class to scale the loss and <nl> + gradients . This can either be an int / float to use a fixed loss scale , <nl> + the string " dynamic " to use dynamic loss scaling , or an instance of a <nl> + LossScale class . The string " dynamic " is equivalent to passing <nl> + ` DynamicLossScale ( ) ` , and passing an int / float is equivalent <nl> + to passing a FixedLossScale instance with the given loss scale . <nl> + " " " <nl> + def __init__ ( self , opt , loss_scale ) : <nl> + if not isinstance ( opt , optimizer . Optimizer ) : <nl> + raise ValueError ( ' " opt " must be an instance of Optimizer , but got : % s ' % <nl> + type ( opt ) ) <nl> + self . _optimizer = opt <nl> + <nl> + use_locking = opt . _use_locking # pylint : disable = protected - access <nl> + name = opt . get_name ( ) <nl> + super ( LossScaleOptimizer , self ) . __init__ ( use_locking , name ) <nl> + <nl> + self . _loss_scale = loss_scale_module . get ( loss_scale ) <nl> + self . _track_trackable ( self . _optimizer , ' base_optimizer ' ) <nl> + self . _track_trackable ( self . _loss_scale , ' loss_scale ' ) <nl> + <nl> + <nl> + def _doing_dynamic_loss_scaling ( self ) : <nl> + " " " Check if ` _loss_scale ` dynamically manages the loss scale . " " " <nl> + return isinstance ( self . _loss_scale , <nl> + loss_scale_module . DynamicLossScale ) <nl> + <nl> + <nl> + def compute_gradients ( self , loss , var_list = None , <nl> + gate_gradients = optimizer . Optimizer . GATE_OP , <nl> + aggregation_method = None , <nl> + colocate_gradients_with_ops = False , <nl> + grad_loss = None ) : <nl> + " " " Compute gradients of ` loss ` for the variables in ` var_list ` . <nl> + <nl> + This adjusts the dynamic range of the gradient evalutaion by scaling up <nl> + the ` loss ` value . The gradient values are then scaled back down by the <nl> + recipricol of the loss scale . This is useful in reduced precision training <nl> + where small gradient values would otherwise underflow the representable <nl> + range . <nl> + <nl> + Args : <nl> + loss : A Tensor containing the value to minimize or a callable taking <nl> + no arguments which returns the value to minimize . When eager execution <nl> + is enabled it must be a callable . <nl> + var_list : Optional list or tuple of ` tf . Variable ` to update to minimize <nl> + ` loss ` . Defaults to the list of variables collected in the graph <nl> + under the key ` GraphKeys . TRAINABLE_VARIABLES ` . <nl> + gate_gradients : How to gate the computation of gradients . Can be <nl> + ` GATE_NONE ` , ` GATE_OP ` , or ` GATE_GRAPH ` . <nl> + aggregation_method : Specifies the method used to combine gradient terms . <nl> + Valid values are defined in the class ` AggregationMethod ` . <nl> + colocate_gradients_with_ops : If True , try colocating gradients with <nl> + the corresponding op . <nl> + grad_loss : Optional . A ` Tensor ` holding the gradient computed for ` loss ` . <nl> + <nl> + Returns : <nl> + A list of ( gradient , variable ) pairs . Variable is always present , but <nl> + gradient can be ` None ` . <nl> + " " " <nl> + loss = self . _scale_loss ( loss ) <nl> + grads_and_vars = self . _optimizer . compute_gradients ( <nl> + loss = loss , var_list = var_list , gate_gradients = gate_gradients , <nl> + aggregation_method = aggregation_method , <nl> + colocate_gradients_with_ops = colocate_gradients_with_ops , <nl> + grad_loss = grad_loss ) <nl> + <nl> + grads = [ g for g , _ in grads_and_vars ] <nl> + variables = [ v for _ , v in grads_and_vars ] <nl> + scaled_grads = self . _scale_grads ( grads ) <nl> + return list ( zip ( scaled_grads , variables ) ) <nl> + <nl> + def _scale_loss ( self , loss ) : <nl> + # The loss is callable for ` _compute_gradients ` , but not ` get_gradients ` . <nl> + loss_scale = self . _loss_scale ( ) <nl> + if callable ( loss ) : <nl> + return lambda : loss ( ) * loss_scale <nl> + return loss * loss_scale <nl> + <nl> + def _scale_grads ( self , grads ) : <nl> + loss_scale = self . _loss_scale ( ) <nl> + loss_scale_reciprical = 1 / loss_scale <nl> + return [ None if g is None else self . _indexed_slices ( <nl> + g , loss_scale_reciprical ) for g in grads ] <nl> + <nl> + def _indexed_slices ( self , grad , loss_scale_reciprical ) : <nl> + if isinstance ( grad , ops . IndexedSlices ) : <nl> + grad_vals = grad . values * loss_scale_reciprical <nl> + return ops . IndexedSlices ( grad_vals , grad . indices , grad . dense_shape ) <nl> + return grad * loss_scale_reciprical <nl> + <nl> + def apply_gradients ( self , grads_and_vars , global_step = None , name = None ) : <nl> + " " " Apply gradients to variables . <nl> + <nl> + This is the second part of ` minimize ( ) ` . It returns an ` Operation ` that <nl> + conditionally applies gradients if all gradient values are finite . <nl> + Otherwise no update is performed ( nor is ` global_step ` incremented ) . <nl> + <nl> + Args : <nl> + grads_and_vars : List of ( gradient , variable ) pairs as returned by <nl> + ` compute_gradients ( ) ` . <nl> + global_step : Optional ` Variable ` to increment by one after the <nl> + variables have been updated . <nl> + name : Optional name for the returned operation . Default to the name <nl> + passed to the ` Optimizer ` constructor . <nl> + <nl> + Returns : <nl> + An ` Operation ` that conditionally applies the specified gradients . If <nl> + ` global_step ` was not None , that operation also increments ` global_step ` . <nl> + <nl> + Raises : <nl> + RuntimeError : If you should use ` _distributed_apply ( ) ` instead . <nl> + " " " <nl> + if distribution_strategy_context . in_cross_replica_context ( ) : <nl> + raise ValueError ( ' apply_gradients ( ) must be called in a replica context . ' ) <nl> + <nl> + if not self . _doing_dynamic_loss_scaling ( ) : <nl> + return self . _optimizer . apply_gradients ( grads_and_vars , global_step , name ) <nl> + <nl> + replica_context = distribution_strategy_context . get_replica_context ( ) <nl> + <nl> + # TODO ( nluehr ) cleanup GraphKeys . TRAIN_OP <nl> + return replica_context . merge_call ( <nl> + self . _maybe_apply_gradients_cross_replica , <nl> + args = ( grads_and_vars , global_step , name ) ) <nl> + <nl> + def _distributed_apply ( self , <nl> + distribution , <nl> + grads_and_vars , <nl> + global_step = None , <nl> + name = None ) : <nl> + " " " A version of ` apply_gradients ` for cross replica context . <nl> + <nl> + When users are in a cross replica strategy , they must call this rather than <nl> + ` apply_gradients ( ) ` . <nl> + <nl> + Args : <nl> + distribution : a ` DistributionStrategy ` object . <nl> + grads_and_vars : List of ( gradient , variable ) pairs as returned by <nl> + ` compute_gradients ( ) ` and then aggregated across replicas . <nl> + global_step : Optional ( mirrored ) ` Variable ` to increment by one <nl> + after the variables have been updated . <nl> + name : Optional name for the returned operation . Default to the name <nl> + passed to the ` Optimizer ` constructor . <nl> + <nl> + Returns : <nl> + An ` Operation ` that applies the specified gradients across all <nl> + replicas . If ` global_step ` was not None , that operation also <nl> + increments ` global_step ` <nl> + " " " <nl> + self . _maybe_apply_gradients_cross_replica ( distribution , grads_and_vars , <nl> + global_step , name ) <nl> + <nl> + def _maybe_apply_gradients_cross_replica ( self , distribution , grads_and_vars , <nl> + global_step , name ) : <nl> + " " " Conditionally apply gradients in cross replica context . " " " <nl> + name = name if name is not None else self . get_name ( ) <nl> + grads = [ g for g , _ in grads_and_vars ] <nl> + loss_scale_update_op , should_apply_grads = ( <nl> + self . _loss_scale . update ( grads ) ) <nl> + maybe_apply_op = smart_cond . smart_cond ( <nl> + should_apply_grads , <nl> + lambda : self . _apply_gradients_cross_replica ( distribution , <nl> + grads_and_vars , <nl> + global_step , <nl> + name + ' - wrapped ' ) , <nl> + control_flow_ops . no_op ) <nl> + return control_flow_ops . group ( maybe_apply_op , loss_scale_update_op , <nl> + name = name ) <nl> + <nl> + def _apply_gradients_cross_replica ( self , distribution , grads_and_vars , <nl> + global_step , name ) : <nl> + " " " Unconditionally apply gradients in cross replica context . " " " <nl> + update_ops = distribution . extended . call_for_each_replica ( <nl> + self . _optimizer . apply_gradients , <nl> + args = ( grads_and_vars , global_step , name ) ) <nl> + return distribution . group ( update_ops ) <nl> + <nl> + def _apply_sparse ( self , grad , var ) : <nl> + " " " This function should never be called " " " <nl> + raise RuntimeError ( " This function should never be called " ) <nl> + <nl> + def _apply_dense ( self , grad , var ) : <nl> + " " " This function should never be called " " " <nl> + raise RuntimeError ( " This function should never be called " ) <nl> + <nl> + def _resource_apply_sparse ( self , grad , handle , indices ) : <nl> + " " " This function should never be called " " " <nl> + raise RuntimeError ( " This function should never be called " ) <nl> + <nl> + def _resource_apply_dense ( self , grad , handle ) : <nl> + " " " This function should never be called " " " <nl> + raise RuntimeError ( " This function should never be called " ) <nl> new file mode 100644 <nl> index 0000000000000 . . 3ee38cb87c572 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / training / loss_scale_optimizer_test . py <nl> <nl> + # Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for LossScaleOptimizer . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import os <nl> + <nl> + from absl . testing import parameterized <nl> + <nl> + from tensorflow . python . distribute import distribution_strategy_context <nl> + from tensorflow . python . distribute import mirrored_strategy <nl> + from tensorflow . python . eager import context <nl> + from tensorflow . python . framework import test_util <nl> + from tensorflow . python . training import loss_scale as loss_scale_module <nl> + from tensorflow . python . training import loss_scale_optimizer <nl> + from tensorflow . python . keras . mixed_precision . experimental import test_util as mp_test_util <nl> + from tensorflow . python . training import gradient_descent <nl> + from tensorflow . python . training import momentum <nl> + from tensorflow . python . ops import resource_variable_ops <nl> + from tensorflow . python . ops import variables <nl> + from tensorflow . python . platform import test <nl> + from tensorflow . python . training . tracking import util as trackable_utils <nl> + <nl> + <nl> + # If called outside any strategy . scope ( ) calls , this will return the default <nl> + # strategy . <nl> + default_strategy_fn = distribution_strategy_context . get_strategy <nl> + <nl> + <nl> + def create_mirrored_strategy ( ) : <nl> + if context . num_gpus ( ) > = 1 : <nl> + return mirrored_strategy . MirroredStrategy ( [ ' cpu : 0 ' , ' gpu : 0 ' ] ) <nl> + else : <nl> + return mirrored_strategy . MirroredStrategy ( [ ' cpu : 0 ' ] ) <nl> + <nl> + <nl> + TESTCASES = ( { <nl> + ' testcase_name ' : ' Base ' , <nl> + ' strategy_fn ' : default_strategy_fn <nl> + } , { <nl> + ' testcase_name ' : ' Distribute ' , <nl> + ' strategy_fn ' : create_mirrored_strategy <nl> + } ) <nl> + <nl> + def get_gradients ( opt , loss , params ) : <nl> + grads_and_vars = opt . compute_gradients ( loss , params ) <nl> + grads , _ = zip ( * grads_and_vars ) <nl> + return grads <nl> + <nl> + class LossScaleOptimizerTest ( test . TestCase , parameterized . TestCase ) : <nl> + <nl> + def _run_if_in_graph_mode ( self , val ) : <nl> + # Running only in graph mode is useful , because optimizers sometimes return <nl> + # a value that , in Graph mode , is runnable with self . evaluate . But in Eager <nl> + # mode , the optimizer already does the computations and the return value <nl> + # cannot be run . <nl> + if not context . executing_eagerly ( ) : <nl> + self . evaluate ( val ) <nl> + <nl> + def _run_fn_with_grad_check ( self , strategy , var , opt , expected_grad ) : <nl> + grad_check_fn = mp_test_util . create_identity_with_grad_check_fn ( <nl> + expected_grad ) <nl> + loss = lambda : grad_check_fn ( var ) / strategy . num_replicas_in_sync <nl> + return lambda : opt . minimize ( loss , var_list = [ var ] ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testFixedLossScaleAppliedToLossWithMinimize ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) as strategy : <nl> + var = variables . Variable ( [ 5 . 0 ] ) <nl> + opt = gradient_descent . GradientDescentOptimizer ( 2 . 0 ) <nl> + loss_scale = 10 . <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + # We need num_replicas_in_sync to divide loss_scale , otherwise loss_scale <nl> + # / strategy . num_replicas_in_sync will not be exact , which could lead to <nl> + # assertion failures due to rounding issues . <nl> + self . assertEqual ( loss_scale % strategy . num_replicas_in_sync , 0 ) <nl> + run_fn = self . _run_fn_with_grad_check ( <nl> + strategy , var , opt , loss_scale / strategy . num_replicas_in_sync ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # The loss is the identity of the variable . Therefore the gradient is 1 , <nl> + # and so the variable will be init_val - grad * lr = = 5 - 1 * 2 = = 3 <nl> + self . assertAllClose ( [ 3 . ] , self . evaluate ( var ) ) <nl> + <nl> + @ test_util . deprecated_graph_mode_only <nl> + def testFixedLossScaleAppliedToLossWithGetGradients ( self ) : <nl> + var = variables . Variable ( [ 2 . 0 ] ) <nl> + opt = gradient_descent . GradientDescentOptimizer ( 1 . 0 ) <nl> + loss_scale = 10 . <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + grad_check_fn = mp_test_util . create_identity_with_grad_check_fn ( loss_scale ) <nl> + loss = grad_check_fn ( var ) <nl> + run_op = get_gradients ( opt , loss , [ var ] ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + # This will cause an assertion to run , as <nl> + # mp_test_util . create_identity_with_grad_check_fn added an assertion op . <nl> + self . evaluate ( run_op ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testDynamicLossScale ( self , strategy_fn ) : <nl> + strategy = strategy_fn ( ) <nl> + learning_rate = 2 . <nl> + expected_gradient = resource_variable_ops . ResourceVariable ( <nl> + learning_rate / strategy . num_replicas_in_sync ) <nl> + with strategy . scope ( ) : <nl> + var = variables . Variable ( [ 5 . 0 ] ) <nl> + opt = gradient_descent . GradientDescentOptimizer ( learning_rate ) <nl> + loss_scale = loss_scale_module . DynamicLossScale ( <nl> + initial_loss_scale = 2 , increment_period = 1 , multiplier = 2 ) <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + self . assertEqual ( <nl> + loss_scale . initial_loss_scale % strategy . num_replicas_in_sync , 0 ) <nl> + <nl> + run_fn = self . _run_fn_with_grad_check ( strategy , var , opt , <nl> + expected_gradient ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # The loss is the identity of the variable . Therefore the gradient is 1 , <nl> + # and so the variable will be init_val - grad * lr = = 5 - 1 * 2 = = 3 <nl> + self . assertAllClose ( [ 3 . ] , self . evaluate ( var ) ) <nl> + <nl> + # Loss scale will be double , so the expected gradient is also doubled . <nl> + self . evaluate ( expected_gradient . assign ( <nl> + 2 * learning_rate / strategy . num_replicas_in_sync ) ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # As before , the 2 is subtracted from the variable , making it ' s new value <nl> + # 1 . <nl> + self . assertAllClose ( [ 1 . ] , self . evaluate ( var ) ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testDynamicUpdate ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) as strategy : <nl> + var = variables . Variable ( [ 1 . 0 , 2 . 0 ] ) <nl> + opt = gradient_descent . GradientDescentOptimizer ( 1 . 0 ) <nl> + loss_scale = loss_scale_module . DynamicLossScale ( <nl> + initial_loss_scale = 2 , increment_period = 1 , multiplier = 2 ) <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + <nl> + # Test optimizer with finite gradients <nl> + loss = lambda : var * 2 . 0 / strategy . num_replicas_in_sync <nl> + run_fn = lambda : opt . minimize ( loss , var_list = [ var ] ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # Gradient is 2 , so variable will have 2 subtracted from it <nl> + self . assertAllClose ( [ - 1 . 0 , 0 . 0 ] , self . evaluate ( var ) ) <nl> + # Loss scale has doubled from 2 to 4 <nl> + self . assertEqual ( 4 . , self . evaluate ( opt . _loss_scale ( ) ) ) <nl> + <nl> + # Test optimizer with NaN gradients <nl> + loss = lambda : var * float ( ' NaN ' ) <nl> + run_fn = lambda : opt . minimize ( loss , var_list = [ var ] ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # Variable should not change from before , due to NaN gradients . <nl> + self . assertAllClose ( self . evaluate ( var ) , [ - 1 . 0 , 0 . 0 ] ) <nl> + # Loss scale should half due to NaN gradients . <nl> + self . assertEqual ( 2 . , self . evaluate ( opt . _loss_scale ( ) ) ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testDynamicLossScaleWithSlots ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) as strategy : <nl> + var = variables . Variable ( [ 1 . 0 , 2 . 0 ] ) <nl> + # An SGD optimizer with momentum has slot variables . <nl> + opt = momentum . MomentumOptimizer ( 1 . 0 , momentum = 1 . ) <nl> + initial_loss_scale = 2 . <nl> + loss_scale = loss_scale_module . DynamicLossScale ( <nl> + initial_loss_scale = initial_loss_scale , increment_period = 1 , <nl> + multiplier = 4 ) <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + loss = lambda : var / strategy . num_replicas_in_sync <nl> + run_fn = lambda : opt . minimize ( loss , var_list = [ var ] ) <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # The momentum accumulator starts at 0 and the gradient is 1 . The <nl> + # accumulator is incremented by the gradient , so it is now 1 . Then the <nl> + # variable is subtracted by the accumulator , so the variable is subtracted <nl> + # by 1 . <nl> + self . assertAllClose ( [ 0 . 0 , 1 . 0 ] , self . evaluate ( var ) ) <nl> + self . assertEqual ( self . evaluate ( opt . _loss_scale ( ) ) , initial_loss_scale * 4 ) <nl> + <nl> + run_op = strategy . experimental_run ( run_fn ) <nl> + self . _run_if_in_graph_mode ( run_op ) <nl> + # The momentum accumulator was 1 before this step and the gradient is 1 . <nl> + # The accumulator is incremented by the gradient , so it is now 2 . Then the <nl> + # variable is subtracted by the accumulator , so the variable is subtracted <nl> + # by 2 . <nl> + self . assertAllClose ( [ - 2 . , - 1 . ] , self . evaluate ( var ) ) <nl> + self . assertEqual ( self . evaluate ( opt . _loss_scale ( ) ) , <nl> + initial_loss_scale * 16 ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testCheckpoint ( self , strategy_fn ) : <nl> + strategy = strategy_fn ( ) <nl> + if ( isinstance ( strategy , mirrored_strategy . MirroredStrategy ) and <nl> + not context . executing_eagerly ( ) ) : <nl> + # TODO ( b / 121381184 ) : Enable running the test in this case . <nl> + return <nl> + <nl> + with self . test_session ( ) , strategy . scope ( ) : <nl> + # Build and run a simple model . <nl> + var = variables . Variable ( [ 2 . 0 ] ) <nl> + loss_scale = loss_scale_module . DynamicLossScale ( <nl> + initial_loss_scale = 1 . , increment_period = 2 . , <nl> + multiplier = 2 . ) <nl> + opt = momentum . MomentumOptimizer ( 1 . 0 , momentum = 1 . ) <nl> + opt = loss_scale_optimizer . LossScaleOptimizer ( opt , loss_scale ) <nl> + run_fn = lambda : opt . minimize ( lambda : var + 1 . , var_list = [ var ] ) <nl> + opt_op = strategy . experimental_run ( run_fn ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + self . evaluate ( opt_op ) <nl> + self . assertEqual ( self . evaluate ( loss_scale ( ) ) , 1 . ) <nl> + self . assertEqual ( self . evaluate ( loss_scale . _num_good_steps ) , 1 ) <nl> + <nl> + # Save a checkpoint . <nl> + checkpoint = trackable_utils . Checkpoint ( optimizer = opt ) <nl> + prefix = os . path . join ( self . get_temp_dir ( ) , ' ckpt ' ) <nl> + save_path = checkpoint . save ( prefix ) <nl> + <nl> + # Run model again . <nl> + self . evaluate ( strategy . experimental_run ( run_fn ) ) <nl> + self . assertEqual ( self . evaluate ( loss_scale ( ) ) , 2 . ) <nl> + self . assertEqual ( self . evaluate ( loss_scale . _num_good_steps ) , 0 ) <nl> + <nl> + # Load checkpoint and ensure loss scale is back to it ' s original value . <nl> + status = checkpoint . restore ( save_path ) <nl> + status . assert_consumed ( ) <nl> + status . run_restore_ops ( ) <nl> + self . assertEqual ( self . evaluate ( loss_scale ( ) ) , 1 . ) <nl> + self . assertEqual ( self . evaluate ( loss_scale . _num_good_steps ) , 1 ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + test . main ( ) <nl> new file mode 100644 <nl> index 0000000000000 . . edf062cf76269 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / training / loss_scale_test . py <nl> <nl> + # Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for LossScale classes . . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + from absl . testing import parameterized <nl> + import numpy as np <nl> + <nl> + from tensorflow . python . data . ops import dataset_ops <nl> + from tensorflow . python . distribute import distribution_strategy_context <nl> + from tensorflow . python . distribute import mirrored_strategy <nl> + from tensorflow . python . eager import context <nl> + from tensorflow . python . framework import constant_op <nl> + from tensorflow . python . framework import ops <nl> + from tensorflow . python . framework import test_util <nl> + from tensorflow . python . training import loss_scale as loss_scale_module <nl> + from tensorflow . python . ops import array_ops <nl> + from tensorflow . python . ops import check_ops <nl> + from tensorflow . python . ops import control_flow_ops <nl> + from tensorflow . python . ops import math_ops <nl> + from tensorflow . python . ops import variables <nl> + from tensorflow . python . platform import test <nl> + <nl> + <nl> + # If called outside any strategy . scope ( ) calls , this will return the default <nl> + # strategy . <nl> + default_strategy_fn = distribution_strategy_context . get_strategy <nl> + <nl> + <nl> + def create_mirrored_strategy ( ) : <nl> + if context . num_gpus ( ) > = 1 : <nl> + return mirrored_strategy . MirroredStrategy ( [ ' cpu : 0 ' , ' gpu : 0 ' ] ) <nl> + else : <nl> + return mirrored_strategy . MirroredStrategy ( [ ' cpu : 0 ' ] ) <nl> + <nl> + <nl> + TESTCASES = ( { <nl> + ' testcase_name ' : ' base ' , <nl> + ' strategy_fn ' : default_strategy_fn <nl> + } , { <nl> + ' testcase_name ' : ' distribute ' , <nl> + ' strategy_fn ' : create_mirrored_strategy <nl> + } ) <nl> + <nl> + <nl> + class FixedLossScaleTest ( test . TestCase ) : <nl> + <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_basic ( self ) : <nl> + loss_scale_value = 1000 <nl> + loss_scale = loss_scale_module . FixedLossScale ( loss_scale_value ) <nl> + <nl> + update_op , should_apply = loss_scale . update ( [ constant_op . constant ( 0 . ) ] ) <nl> + self . evaluate ( update_op ) <nl> + # should_apply should be a bool instead of a tensor , so that a tf . cond does <nl> + # not have to be built in the graph by the caller . <nl> + self . assertIsInstance ( should_apply , bool ) <nl> + self . assertTrue ( should_apply ) <nl> + self . assertEqual ( loss_scale_value , self . evaluate ( loss_scale ( ) ) ) <nl> + <nl> + update_op , should_apply = loss_scale . update ( <nl> + [ constant_op . constant ( float ( ' NaN ' ) ) ] ) <nl> + self . evaluate ( update_op ) <nl> + self . assertIsInstance ( should_apply , bool ) <nl> + self . assertTrue ( should_apply ) <nl> + self . assertEqual ( loss_scale_value , self . evaluate ( loss_scale ( ) ) ) <nl> + <nl> + <nl> + def _get_example_iter ( inputs ) : <nl> + dataset = dataset_ops . Dataset . from_tensor_slices ( inputs ) <nl> + return dataset_ops . make_one_shot_iterator ( dataset ) <nl> + <nl> + <nl> + class DynamicLossScaleTest ( test . TestCase , parameterized . TestCase ) : <nl> + <nl> + def _get_tensor ( self , is_finite ) : <nl> + tensor = control_flow_ops . cond ( is_finite , lambda : 1 . , lambda : float ( ' NaN ' ) ) <nl> + <nl> + if not distribution_strategy_context . has_strategy ( ) : <nl> + return tensor <nl> + def get ( ) : <nl> + rep_id = ( distribution_strategy_context . get_replica_context ( ) <nl> + . replica_id_in_sync_group ) <nl> + return control_flow_ops . cond ( math_ops . equal ( rep_id , 0 ) , lambda : tensor , <nl> + lambda : 1 . ) <nl> + distribution = distribution_strategy_context . get_strategy ( ) <nl> + return distribution . extended . call_for_each_replica ( get ) <nl> + <nl> + def _test_helper ( self , <nl> + inputs , <nl> + expected_outputs , <nl> + initial_loss_scale = 1 . , <nl> + increment_period = 2 , <nl> + multiplier = 2 ) : <nl> + loss_scale = loss_scale_module . DynamicLossScale ( <nl> + initial_loss_scale = initial_loss_scale , <nl> + increment_period = increment_period , <nl> + multiplier = multiplier ) <nl> + itr = _get_example_iter ( inputs ) <nl> + <nl> + def update ( ) : <nl> + is_finite = itr . get_next ( ) <nl> + grad = self . _get_tensor ( is_finite ) <nl> + update_op , should_apply_gradients = loss_scale . update ( [ grad ] ) <nl> + assert_op = check_ops . assert_equal ( should_apply_gradients , is_finite ) <nl> + if context . executing_eagerly ( ) : <nl> + return <nl> + with ops . control_dependencies ( [ assert_op ] ) : <nl> + return array_ops . identity ( update_op ) <nl> + <nl> + actual_outputs = [ ] <nl> + <nl> + if not context . executing_eagerly ( ) : <nl> + update_op = update ( ) <nl> + self . evaluate ( variables . global_variables_initializer ( ) ) <nl> + for _ in range ( len ( inputs ) ) : <nl> + if context . executing_eagerly ( ) : <nl> + update ( ) <nl> + else : <nl> + self . evaluate ( update_op ) <nl> + actual_outputs . append ( self . evaluate ( loss_scale ( ) ) ) <nl> + self . assertEqual ( actual_outputs , expected_outputs ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_increase ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + inputs = [ True ] * 6 <nl> + expected_outputs = [ 1 , 2 , 2 , 4 , 4 , 8 ] <nl> + self . _test_helper ( inputs , expected_outputs ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_keep_increasing_until_capped ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = np . finfo ( np . float32 ) . max / 4 <nl> + max_float = np . finfo ( np . float32 ) . max <nl> + <nl> + inputs = [ True ] * 6 <nl> + # Output is capped the 2nd time it doubles . <nl> + expected_outputs = [ <nl> + init_loss_scale , init_loss_scale * 2 , init_loss_scale * 2 , max_float , <nl> + max_float , max_float <nl> + ] <nl> + <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_decrease_every_step ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + inputs = [ False ] * 6 <nl> + init_loss_scale = 1024 <nl> + expected_outputs = [ 512 , 256 , 128 , 64 , 32 , 16 ] <nl> + <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_keep_decreasing_until_one ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + inputs = [ False ] * 6 <nl> + init_loss_scale = 16 <nl> + expected_outputs = [ 8 , 4 , 2 , 1 , 1 , 1 ] <nl> + <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_nan_clear_good_step ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + inputs = [ True , True , True , False , True ] <nl> + expected_outputs = [ 1 , 2 , 2 , 1 , 1 ] <nl> + self . _test_helper ( inputs , expected_outputs ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_trigger_loss_scale_update_each_step ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = 1 <nl> + increment_period = 1 <nl> + <nl> + inputs = [ True ] * 3 + [ False , True , True ] <nl> + expected_outputs = [ 2 , 4 , 8 , 4 , 8 , 16 ] <nl> + <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale , <nl> + increment_period ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_alternating_good_and_bad_gradients_trigger_each_step ( self , <nl> + strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = 1 <nl> + increment_period = 1 <nl> + <nl> + inputs = [ True , False ] * 4 + [ True ] <nl> + expected_outputs = [ 2 , 1 , 2 , 1 , 2 , 1 , 2 , 1 , 2 ] <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale , <nl> + increment_period ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_alternating_good_and_bad_gradients_trigger_every_other_step ( <nl> + self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = 32 <nl> + increment_period = 2 <nl> + <nl> + inputs = [ True , False ] * 3 + [ True ] <nl> + expected_outputs = [ 32 , 16 , 16 , 8 , 8 , 4 , 4 ] <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale , <nl> + increment_period ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_nondefault_multiplier ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = 4 <nl> + multiplier = 3 <nl> + inputs = [ True , True , False , True , True ] <nl> + expected_outputs = [ 4 , 12 , 4 , 4 , 12 ] <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale , <nl> + multiplier = multiplier ) <nl> + <nl> + @ parameterized . named_parameters ( * TESTCASES ) <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_random_mix_good_and_bad_gradients ( self , strategy_fn ) : <nl> + with strategy_fn ( ) . scope ( ) : <nl> + init_loss_scale = 4 <nl> + inputs = [ <nl> + False , True , True , True , False , True , False , True , True , True , False <nl> + ] <nl> + expected_outputs = [ 2 , 2 , 4 , 4 , 2 , 2 , 1 , 1 , 2 , 2 , 1 ] <nl> + self . _test_helper ( inputs , expected_outputs , init_loss_scale ) <nl> + <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def test_get ( self ) : <nl> + scalar = loss_scale_module . get ( ' dynamic ' ) <nl> + scalar2 = loss_scale_module . DynamicLossScale ( ) <nl> + self . assertEqual ( scalar . initial_loss_scale , scalar2 . initial_loss_scale ) <nl> + self . assertEqual ( scalar . increment_period , scalar2 . increment_period ) <nl> + self . assertEqual ( scalar . multiplier , <nl> + scalar2 . multiplier ) <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + test . main ( ) <nl> mmm a / tensorflow / python / training / training . py <nl> ppp b / tensorflow / python / training / training . py <nl> <nl> from tensorflow . python . training . proximal_adagrad import ProximalAdagradOptimizer <nl> from tensorflow . python . training . adam import AdamOptimizer <nl> from tensorflow . python . training . ftrl import FtrlOptimizer <nl> + from tensorflow . python . training . loss_scale import FixedLossScale , DynamicLossScale <nl> + from tensorflow . python . training . loss_scale_optimizer import LossScaleOptimizer <nl> from tensorflow . python . training . momentum import MomentumOptimizer <nl> from tensorflow . python . training . moving_averages import ExponentialMovingAverage <nl> from tensorflow . python . training . optimizer import Optimizer <nl> | Add loss scale optimizer for v1 optimizers | tensorflow/tensorflow | 83bfd7e23cbcd16403bef3ebc0787fdb655d93f6 | 2019-04-08T22:13:47Z |
mmm a / dbms / src / Storages / MergeTree / MergeTreeDataMergerMutator . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataMergerMutator . cpp <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> new_data_part - > is_temp = true ; <nl> <nl> String new_part_tmp_path = new_data_part - > getFullPath ( ) ; <nl> + std : : cerr < < " NEW TEMP PART : " < < new_part_tmp_path < < std : : endl ; <nl> <nl> / / / Note : this is done before creating input streams , because otherwise data . data_parts_mutex <nl> / / / ( which is locked in data . getTotalActiveSizeInBytes ( ) ) is locked after part - > columns_lock <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> { <nl> String stream_name = IDataType : : getFileNameForStream ( entry . name , substream_path ) ; <nl> files_to_skip . insert ( stream_name + " . bin " ) ; <nl> - files_to_skip . insert ( stream_name + " . mrk " ) ; <nl> + files_to_skip . insert ( stream_name + new_data_part - > marks_file_extension ) ; <nl> } ; <nl> <nl> IDataType : : SubstreamPath stream_path ; <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> new_data_part - > rows_count = source_part - > rows_count ; <nl> new_data_part - > marks_count = source_part - > marks_count ; <nl> new_data_part - > marks_index_granularity = source_part - > marks_index_granularity ; <nl> + new_data_part - > mark_size_in_bytes = source_part - > mark_size_in_bytes ; <nl> new_data_part - > index = source_part - > index ; <nl> new_data_part - > partition . assign ( source_part - > partition ) ; <nl> new_data_part - > minmax_idx = source_part - > minmax_idx ; <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeDataPart . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataPart . cpp <nl> void MergeTreeDataPart : : MinMaxIndex : : merge ( const MinMaxIndex & other ) <nl> <nl> <nl> MergeTreeDataPart : : MergeTreeDataPart ( MergeTreeData & storage_ , const String & name_ ) <nl> - : storage ( storage_ ) , name ( name_ ) , info ( MergeTreePartInfo : : fromPartName ( name_ , storage . format_version ) ) <nl> + : storage ( storage_ ) <nl> + , name ( name_ ) <nl> + , info ( MergeTreePartInfo : : fromPartName ( name_ , storage . format_version ) ) <nl> + , marks_file_extension ( storage . index_granularity_bytes > 0 ? " . mrk2 " : " . mrk " ) <nl> { <nl> } <nl> <nl> + MergeTreeDataPart : : MergeTreeDataPart ( const MergeTreeData & storage_ , const String & name_ , const MergeTreePartInfo & info_ ) <nl> + : storage ( storage_ ) <nl> + , name ( name_ ) <nl> + , info ( info_ ) <nl> + , marks_file_extension ( storage . index_granularity_bytes > 0 ? " . mrk2 " : " . mrk " ) <nl> + { <nl> + } <nl> + <nl> + <nl> / / / Takes into account the fact that several columns can e . g . share their . size substreams . <nl> / / / When calculating totals these should be counted only once . <nl> MergeTreeDataPart : : ColumnSize MergeTreeDataPart : : getColumnSizeImpl ( <nl> String MergeTreeDataPart : : getColumnNameWithMinumumCompressedSize ( ) const <nl> <nl> for ( const auto & column : storage_columns ) <nl> { <nl> - / / std : : cerr < < " Searching for column : " < < column . name < < std : : endl ; <nl> + std : : cerr < < " Searching for column : " < < column . name < < std : : endl ; <nl> if ( ! hasColumnFiles ( column . name ) ) <nl> + { <nl> + std : : cerr < < " No column files : " < < column . name < < std : : endl ; <nl> continue ; <nl> + } <nl> <nl> const auto size = getColumnSize ( column . name , * column . type ) . data_compressed ; <nl> - / / std : : cerr < < " Column size : " < < size < < std : : endl ; <nl> + std : : cerr < < " Column size : " < < size < < std : : endl ; <nl> if ( size < minimum_size ) <nl> { <nl> minimum_size = size ; <nl> void MergeTreeDataPart : : loadMarksIndexGranularity ( ) <nl> / / / We can use any column , it doesn ' t matter <nl> std : : string marks_file_path = getFullPath ( ) + escapeForFileName ( columns . front ( ) . name ) ; <nl> / / std : : cerr < < " MARKSFILEPATH : " < < marks_file_path < < std : : endl ; <nl> - if ( Poco : : File ( marks_file_path + " . mrk " ) . exists ( ) ) <nl> - { <nl> - marks_file_extension = " . mrk " ; <nl> - / / std : : cerr < < " EXISTS . mrk " < < getFullPath ( ) < < std : : endl ; <nl> - } <nl> - else if ( Poco : : File ( marks_file_path + " . mrk2 " ) . exists ( ) ) <nl> - { <nl> - marks_file_extension = " . mrk2 " ; <nl> - / / std : : cerr < < " EXISTS . mrk2 : " < < getFullPath ( ) < < std : : endl ; <nl> - } <nl> - else <nl> - throw Exception ( " Marks file ' " + marks_file_path + " ' doesn ' t exist with extensions . mrk or mrk2 " , ErrorCodes : : NO_FILE_IN_DATA_PART ) ; <nl> + if ( ! Poco : : File ( marks_file_path + marks_file_extension ) . exists ( ) ) <nl> + throw Exception ( " Marks file ' " + marks_file_path + " ' doesn ' t exist with extension " + marks_file_extension , ErrorCodes : : NO_FILE_IN_DATA_PART ) ; <nl> <nl> marks_file_path + = marks_file_extension ; <nl> size_t marks_file_size = Poco : : File ( marks_file_path ) . getSize ( ) ; <nl> void MergeTreeDataPart : : loadMarksIndexGranularity ( ) <nl> if ( marks_file_extension = = " . mrk " ) <nl> { <nl> mark_size_in_bytes = sizeof ( size_t ) * 2 ; <nl> + std : : cerr < < " ( 1 ) SET MARKS SIZE FOR : " < < marks_file_path < < " TO : " < < mark_size_in_bytes < < std : : endl ; <nl> / / / TODO ( alesap ) Replace hardcoded numbers to something better <nl> marks_count = marks_file_size / mark_size_in_bytes ; <nl> marks_index_granularity . resize ( marks_count , storage . index_granularity ) ; / / / all the same <nl> void MergeTreeDataPart : : loadMarksIndexGranularity ( ) <nl> else <nl> { <nl> mark_size_in_bytes = sizeof ( size_t ) * 3 ; <nl> + std : : cerr < < " ( 2 ) SET MARKS SIZE FOR : " < < marks_file_path < < " TO : " < < mark_size_in_bytes < < std : : endl ; <nl> marks_count = marks_file_size / mark_size_in_bytes ; <nl> ReadBufferFromFile buffer ( marks_file_path , marks_file_size , - 1 ) ; <nl> marks_index_granularity . resize ( marks_count ) ; <nl> bool MergeTreeDataPart : : hasColumnFiles ( const String & column ) const <nl> / / / That ' s Ok under assumption that files exist either for all or for no streams . <nl> <nl> String prefix = getFullPath ( ) ; <nl> - / / std : : cerr < < " ColumnPrefix : " < < prefix < < std : : endl ; <nl> + std : : cerr < < " ColumnPrefix : " < < prefix < < std : : endl ; <nl> <nl> <nl> String escaped_column = escapeForFileName ( column ) ; <nl> - / / std : : cerr < < " Escaped name : " < < escaped_column < < std : : endl ; <nl> - / / std : : cerr < < " Marks file extension : " < < marks_file_extension < < std : : endl ; <nl> + std : : cerr < < " Escaped name : " < < escaped_column < < std : : endl ; <nl> + std : : cerr < < " Marks file extension : " < < marks_file_extension < < std : : endl ; <nl> return Poco : : File ( prefix + escaped_column + " . bin " ) . exists ( ) <nl> & & Poco : : File ( prefix + escaped_column + marks_file_extension ) . exists ( ) ; <nl> } <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeDataPart . h <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataPart . h <nl> struct MergeTreeDataPart <nl> using Checksums = MergeTreeDataPartChecksums ; <nl> using Checksum = MergeTreeDataPartChecksums : : Checksum ; <nl> <nl> - MergeTreeDataPart ( const MergeTreeData & storage_ , const String & name_ , const MergeTreePartInfo & info_ ) <nl> - : storage ( storage_ ) , name ( name_ ) , info ( info_ ) <nl> - { <nl> - } <nl> + MergeTreeDataPart ( const MergeTreeData & storage_ , const String & name_ , const MergeTreePartInfo & info_ ) ; <nl> <nl> MergeTreeDataPart ( MergeTreeData & storage_ , const String & name_ ) ; <nl> <nl> | Fix mutations bug | ClickHouse/ClickHouse | 5aea16e2a0f114020deee922993561e04e942cd1 | 2019-03-22T12:56:58Z |
similarity index 76 % <nl> rename from objectivec / Tests / CocoaPods / OSXCocoaPodsTester / Podfile <nl> rename to objectivec / Tests / CocoaPods / OSXCocoaPodsTester / Podfile - framework <nl> mmm a / objectivec / Tests / CocoaPods / OSXCocoaPodsTester / Podfile <nl> ppp b / objectivec / Tests / CocoaPods / OSXCocoaPodsTester / Podfile - framework <nl> platform : osx , ' 10 . 9 ' <nl> <nl> install ! ' cocoapods ' , : deterministic_uuids = > false <nl> <nl> - if ENV [ ' USE_FRAMEWORKS ' ] = = ' YES ' then <nl> - use_frameworks ! <nl> - end <nl> + use_frameworks ! <nl> <nl> target ' OSXCocoaPodsTester ' do <nl> pod ' Protobuf ' , : path = > ' . . / . . / . . / . . ' <nl> new file mode 100644 <nl> index 0000000000 . . 5dfc8de578 <nl> mmm / dev / null <nl> ppp b / objectivec / Tests / CocoaPods / OSXCocoaPodsTester / Podfile - static <nl> <nl> + source ' https : / / github . com / CocoaPods / Specs . git ' <nl> + platform : osx , ' 10 . 9 ' <nl> + <nl> + install ! ' cocoapods ' , : deterministic_uuids = > false <nl> + <nl> + target ' OSXCocoaPodsTester ' do <nl> + pod ' Protobuf ' , : path = > ' . . / . . / . . / . . ' <nl> + end <nl> similarity index 76 % <nl> rename from objectivec / Tests / CocoaPods / iOSCocoaPodsTester / Podfile <nl> rename to objectivec / Tests / CocoaPods / iOSCocoaPodsTester / Podfile - framework <nl> mmm a / objectivec / Tests / CocoaPods / iOSCocoaPodsTester / Podfile <nl> ppp b / objectivec / Tests / CocoaPods / iOSCocoaPodsTester / Podfile - framework <nl> platform : ios , ' 8 . 0 ' <nl> <nl> install ! ' cocoapods ' , : deterministic_uuids = > false <nl> <nl> - if ENV [ ' USE_FRAMEWORKS ' ] = = ' YES ' then <nl> - use_frameworks ! <nl> - end <nl> + use_frameworks ! <nl> <nl> target ' iOSCocoaPodsTester ' do <nl> pod ' Protobuf ' , : path = > ' . . / . . / . . / . . ' <nl> new file mode 100644 <nl> index 0000000000 . . e9b3c235dd <nl> mmm / dev / null <nl> ppp b / objectivec / Tests / CocoaPods / iOSCocoaPodsTester / Podfile - static <nl> <nl> + source ' https : / / github . com / CocoaPods / Specs . git ' <nl> + platform : ios , ' 8 . 0 ' <nl> + <nl> + install ! ' cocoapods ' , : deterministic_uuids = > false <nl> + <nl> + target ' iOSCocoaPodsTester ' do <nl> + pod ' Protobuf ' , : path = > ' . . / . . / . . / . . ' <nl> + end <nl> mmm a / objectivec / Tests / CocoaPods / run_tests . sh <nl> ppp b / objectivec / Tests / CocoaPods / run_tests . sh <nl> OPTIONS : <nl> EOF <nl> } <nl> <nl> - TEST_MODES = ( " yes " " no " ) <nl> + TEST_MODES = ( " static " " framework " ) <nl> TEST_NAMES = ( " iOSCocoaPodsTester " " OSXCocoaPodsTester " ) <nl> while [ [ $ # ! = 0 ] ] ; do <nl> case " $ { 1 } " in <nl> while [ [ $ # ! = 0 ] ] ; do <nl> exit 0 <nl> ; ; <nl> - - skip - static ) <nl> - TEST_MODES = ( $ { TEST_MODES [ @ ] / no } ) <nl> + TEST_MODES = ( $ { TEST_MODES [ @ ] / static } ) <nl> ; ; <nl> - - skip - framework ) <nl> - TEST_MODES = ( $ { TEST_MODES [ @ ] / yes } ) <nl> + TEST_MODES = ( $ { TEST_MODES [ @ ] / framework } ) <nl> ; ; <nl> - - skip - ios ) <nl> TEST_NAMES = ( $ { TEST_NAMES [ @ ] / iOSCocoaPodsTester } ) <nl> cleanup ( ) { <nl> # incase something does hiccup . <nl> xcodebuild - workspace " $ { TEST_NAME } . xcworkspace " - scheme " $ { TEST_NAME } " clean > / dev / null | | true <nl> pod deintegrate > / dev / null | | true <nl> - # Delete the files left after pod deintegrate <nl> + # Flush the cache so nothing is left behind . <nl> + pod cache clean - - all | | true <nl> + # Delete the files left after pod deintegrate . <nl> rm - f Podfile . lock | | true <nl> rm - rf " $ { TEST_NAME } . xcworkspace " | | true <nl> git checkout - - " $ { TEST_NAME } . xcodeproj " | | true <nl> + # Remove the Podfile that was put in place . <nl> + rm - f Podfile | | true <nl> } <nl> <nl> do_test ( ) { <nl> local TEST_NAME = " $ 1 " <nl> - local USE_FRAMEWORKS_VALUE = " $ 2 " <nl> + local TEST_MODE = " $ 2 " <nl> <nl> - header " $ { TEST_NAME } " - USE_FRAMEWORKS : " $ { USE_FRAMEWORKS_VALUE } " <nl> + header " $ { TEST_NAME } " - Mode : " $ { TEST_MODE } " <nl> cd " $ { ScriptDir } / $ { TEST_NAME } " <nl> <nl> # Hook in cleanup for any failures . <nl> trap " cleanup $ { TEST_NAME } " EXIT <nl> <nl> - # Invoke pod and then xcodebuild , but catch the results so we can cleanup . <nl> - USE_FRAMEWORKS = " $ { USE_FRAMEWORKS_VALUE } " pod install <nl> + # Ensure nothing is cached by pods to start with that could throw things off . <nl> + pod cache clean - - all <nl> + <nl> + # Put the right Podfile in place . <nl> + cp - f " Podfile - $ { TEST_MODE } " " Podfile " <nl> + <nl> + # Do the work ! <nl> + pod install - - verbose <nl> xcodebuild - workspace " $ { TEST_NAME } . xcworkspace " - scheme " $ { TEST_NAME } " build <nl> <nl> # Clear the hook and manually run cleanup . <nl> | Merge pull request from thomasvl / pods_integration_followup | protocolbuffers/protobuf | 5c6518fd2799acc043416640f17f40c916193325 | 2016-05-20T18:57:42Z |
mmm a / lib / SIL / SILVerifier . cpp <nl> ppp b / lib / SIL / SILVerifier . cpp <nl> class SILVerifier : public SILVerifierBase < SILVerifier > { <nl> " [ dynamic_replacement_for : . . . ] function " ) ; <nl> } else if ( isa < DynamicFunctionRefInst > ( FRI ) ) <nl> require ( RefF - > isDynamicallyReplaceable ( ) , <nl> - " dynamic_function_ref cannot reference a " <nl> + " dynamic_function_ref must reference a " <nl> " [ dynamically_replaceable ] function " ) ; <nl> <nl> / / In canonical SIL , direct reference to a shared_external declaration <nl> | Merge pull request from aschwaighofer / fix_assert_prev_dynamic | apple/swift | a2b1e34a6f98505ebfeaa657cb1ffd7b332befad | 2019-05-23T19:59:50Z |
mmm a / include / grpc + + / impl / codegen / server_interface . h <nl> ppp b / include / grpc + + / impl / codegen / server_interface . h <nl> class ServerInterface : public CallHook { <nl> / / / \ param num_cqs How many completion queues does \ a cqs hold . <nl> / / / <nl> / / / \ return true on a successful shutdown . <nl> - virtual bool Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) = 0 ; <nl> + virtual void Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) = 0 ; <nl> <nl> virtual void ShutdownInternal ( gpr_timespec deadline ) = 0 ; <nl> <nl> mmm a / include / grpc + + / server . h <nl> ppp b / include / grpc + + / server . h <nl> class Server final : public ServerInterface , private GrpcLibraryCodegen { <nl> / / / \ param num_cqs How many completion queues does \ a cqs hold . <nl> / / / <nl> / / / \ return true on a successful shutdown . <nl> - bool Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) override ; <nl> + void Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) override ; <nl> <nl> void PerformOpsOnCall ( CallOpSetInterface * ops , Call * call ) override ; <nl> <nl> mmm a / src / core / lib / surface / server . c <nl> ppp b / src / core / lib / surface / server . c <nl> <nl> <nl> # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / channel / connected_channel . h " <nl> + # include " src / core / lib / iomgr / executor . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> # include " src / core / lib / support / stack_lockfree . h " <nl> void * grpc_server_register_method ( <nl> return m ; <nl> } <nl> <nl> + static void start_listeners ( grpc_exec_ctx * exec_ctx , void * s , <nl> + grpc_error * error ) { <nl> + grpc_server * server = s ; <nl> + for ( listener * l = server - > listeners ; l ; l = l - > next ) { <nl> + l - > start ( exec_ctx , server , l - > arg , server - > pollsets , server - > pollset_count ) ; <nl> + } <nl> + server_unref ( exec_ctx , server ) ; <nl> + } <nl> + <nl> void grpc_server_start ( grpc_server * server ) { <nl> - listener * l ; <nl> size_t i ; <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> <nl> void grpc_server_start ( grpc_server * server ) { <nl> ( size_t ) server - > max_requested_calls_per_cq , server ) ; <nl> } <nl> <nl> - for ( l = server - > listeners ; l ; l = l - > next ) { <nl> - l - > start ( & exec_ctx , server , l - > arg , server - > pollsets , <nl> - server - > pollset_count ) ; <nl> - } <nl> + server_ref ( server ) ; <nl> + grpc_closure_sched ( & exec_ctx , grpc_closure_create ( start_listeners , server , <nl> + grpc_executor_scheduler ) , <nl> + GRPC_ERROR_NONE ) ; <nl> <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> } <nl> mmm a / src / cpp / server / server_builder . cc <nl> ppp b / src / cpp / server / server_builder . cc <nl> std : : unique_ptr < Server > ServerBuilder : : BuildAndStart ( ) { <nl> } <nl> <nl> auto cqs_data = cqs_ . empty ( ) ? nullptr : & cqs_ [ 0 ] ; <nl> - if ( ! server - > Start ( cqs_data , cqs_ . size ( ) ) ) { <nl> - if ( added_port ) server - > Shutdown ( ) ; <nl> - return nullptr ; <nl> - } <nl> + server - > Start ( cqs_data , cqs_ . size ( ) ) ; <nl> <nl> for ( auto plugin = plugins_ . begin ( ) ; plugin ! = plugins_ . end ( ) ; plugin + + ) { <nl> ( * plugin ) - > Finish ( initializer ) ; <nl> mmm a / src / cpp / server / server_cc . cc <nl> ppp b / src / cpp / server / server_cc . cc <nl> int Server : : AddListeningPort ( const grpc : : string & addr , <nl> return port ; <nl> } <nl> <nl> - bool Server : : Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) { <nl> + void Server : : Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) { <nl> GPR_ASSERT ( ! started_ ) ; <nl> global_callbacks_ - > PreServerStart ( this ) ; <nl> started_ = true ; <nl> bool Server : : Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) { <nl> for ( auto it = sync_req_mgrs_ . begin ( ) ; it ! = sync_req_mgrs_ . end ( ) ; it + + ) { <nl> ( * it ) - > Start ( ) ; <nl> } <nl> - <nl> - return true ; <nl> } <nl> <nl> void Server : : ShutdownInternal ( gpr_timespec deadline ) { <nl> | Threading robustness | grpc/grpc | 9d9313cfc650e79b44f95d9b7fd9e75e2dc38111 | 2017-04-11T22:05:46Z |
mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / D3DRenderAuxGeom . cpp <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / D3DRenderAuxGeom . cpp <nl> <nl> # include " StdAfx . h " <nl> # include " DriverD3D . h " <nl> # include " D3DRenderAuxGeom . h " <nl> + # include " GraphicsPipeline / StandardGraphicsPipeline . h " <nl> + # include < climits > <nl> <nl> # if defined ( ENABLE_RENDER_AUX_GEOM ) <nl> <nl> typedef std : : vector < vtx_idx > AuxObjIndexBuffer ; <nl> <nl> CRenderAuxGeomD3D : : CRenderAuxGeomD3D ( CD3D9Renderer & renderer ) <nl> : m_renderer ( renderer ) <nl> - , m_pAuxGeomVB ( 0 ) <nl> - , m_pAuxGeomIB ( 0 ) <nl> + , m_geomPass ( false ) <nl> , m_pCurVB ( 0 ) <nl> , m_pCurIB ( 0 ) <nl> - , m_auxGeomSBM ( ) <nl> , m_wndXRes ( 0 ) <nl> , m_wndYRes ( 0 ) <nl> , m_aspect ( 1 . 0f ) <nl> void CRenderAuxGeomD3D : : GetMemoryUsage ( ICrySizer * pSizer ) const <nl> <nl> void CRenderAuxGeomD3D : : ReleaseDeviceObjects ( ) <nl> { <nl> - SAFE_RELEASE ( m_pAuxGeomVB ) ; <nl> - SAFE_RELEASE ( m_pAuxGeomIB ) ; <nl> - <nl> for ( uint32 i ( 0 ) ; i < e_auxObjNumLOD ; + + i ) <nl> { <nl> m_sphereObj [ i ] . Release ( ) ; <nl> int CRenderAuxGeomD3D : : GetDeviceDataSize ( ) <nl> { <nl> int nSize = 0 ; <nl> <nl> - nSize + = _VertBufferSize ( m_pAuxGeomVB ) ; <nl> - nSize + = _IndexBufferSize ( m_pAuxGeomIB ) ; <nl> - <nl> for ( uint32 i = 0 ; i < e_auxObjNumLOD ; + + i ) <nl> { <nl> nSize + = m_sphereObj [ i ] . GetDeviceDataSize ( ) ; <nl> HRESULT CRenderAuxGeomD3D : : RestoreDeviceObjects ( ) <nl> { <nl> HRESULT hr ( S_OK ) ; <nl> <nl> - / / recreate vertex buffer <nl> - SAFE_RELEASE ( m_pAuxGeomVB ) ; <nl> - <nl> - D3D11_BUFFER_DESC BufDescV ; <nl> - ZeroStruct ( BufDescV ) ; <nl> - BufDescV . ByteWidth = e_auxGeomVBSize * sizeof ( SAuxVertex ) ; <nl> - BufDescV . Usage = D3D11_USAGE_DYNAMIC ; <nl> - BufDescV . BindFlags = D3D11_BIND_VERTEX_BUFFER ; <nl> - BufDescV . CPUAccessFlags = D3D11_CPU_ACCESS_WRITE ; <nl> - BufDescV . MiscFlags = 0 ; <nl> - <nl> - if ( FAILED ( hr = m_renderer . GetDevice ( ) . CreateBuffer ( & BufDescV , 0 , & m_pAuxGeomVB ) ) ) <nl> - { <nl> - assert ( 0 ) ; <nl> - return ( hr ) ; <nl> - } <nl> - <nl> - / / recreate index buffer <nl> - SAFE_RELEASE ( m_pAuxGeomIB ) ; <nl> - D3D11_BUFFER_DESC BufDescI ; <nl> - ZeroStruct ( BufDescI ) ; <nl> - BufDescI . ByteWidth = e_auxGeomIBSize * sizeof ( vtx_idx ) ; <nl> - BufDescI . Usage = D3D11_USAGE_DYNAMIC ; <nl> - BufDescI . BindFlags = D3D11_BIND_INDEX_BUFFER ; <nl> - BufDescI . CPUAccessFlags = D3D11_CPU_ACCESS_WRITE ; <nl> - BufDescI . MiscFlags = 0 ; <nl> - if ( FAILED ( hr = m_renderer . GetDevice ( ) . CreateBuffer ( & BufDescI , 0 , & m_pAuxGeomIB ) ) ) <nl> - { <nl> - assert ( 0 ) ; <nl> - return ( hr ) ; <nl> - } <nl> - <nl> - # if ! defined ( RELEASE ) & & CRY_PLATFORM_WINDOWS <nl> - m_pAuxGeomVB - > SetPrivateData ( WKPDID_D3DDebugObjectName , strlen ( " Aux Geom " ) , " Aux Geom " ) ; <nl> - m_pAuxGeomIB - > SetPrivateData ( WKPDID_D3DDebugObjectName , strlen ( " Aux Geom " ) , " Aux Geom " ) ; <nl> - # endif <nl> - <nl> / / recreate aux objects <nl> for ( uint32 i ( 0 ) ; i < e_auxObjNumLOD ; + + i ) <nl> { <nl> HRESULT CRenderAuxGeomD3D : : RestoreDeviceObjects ( ) <nl> return ( hr ) ; <nl> } <nl> <nl> - void CRenderAuxGeomD3D : : DrawAuxPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const CAuxGeomCB : : EPrimType & primType ) <nl> + template < class T = vtx_idx , int size = sizeof ( T ) * CHAR_BIT > struct indexbuffer_type ; <nl> + <nl> + template < class T > struct indexbuffer_type < T , 16 > { static const RenderIndexType type = Index16 ; } ; <nl> + template < class T > struct indexbuffer_type < T , 32 > { static const RenderIndexType type = Index32 ; } ; <nl> + <nl> + <nl> + CRenderAuxGeomD3D : : CBufferManager : : ~ CBufferManager ( ) <nl> { <nl> - assert ( CAuxGeomCB : : e_PtList = = primType | | CAuxGeomCB : : e_LineList = = primType | | CAuxGeomCB : : e_TriList = = primType ) ; <nl> + if ( vbAux ! = ~ 0u ) gcpRendD3D - > m_DevBufMan . Destroy ( vbAux ) ; <nl> + if ( ibAux ! = ~ 0u ) gcpRendD3D - > m_DevBufMan . Destroy ( ibAux ) ; <nl> + } <nl> <nl> - HRESULT hr ( S_OK ) ; <nl> + buffer_handle_t CRenderAuxGeomD3D : : CBufferManager : : update ( BUFFER_BIND_TYPE type , const void * data , size_t size ) <nl> + { <nl> + buffer_handle_t buf = gcpRendD3D - > m_DevBufMan . Create ( type , BU_TRANSIENT , size ) ; / / BU_DYNAMIC <nl> <nl> - / / bind vertex and index streams and set vertex declaration <nl> - bool streamsBound = BindStreams ( eVF_P3F_C4B_T2F , m_pAuxGeomVB , m_pAuxGeomIB ) ; <nl> + gcpRendD3D - > m_DevBufMan . UpdateBuffer ( buf , data , size ) ; <nl> <nl> - / / get aux vertex buffer <nl> - const CAuxGeomCB : : AuxVertexBuffer & auxVertexBuffer ( GetAuxVertexBuffer ( ) ) ; <nl> + return buf ; <nl> + } <nl> <nl> - / / determine flags for prim type <nl> - uint32 d3dNumPrimDivider ; <nl> - ERenderPrimitiveType ePrimType ; <nl> + buffer_handle_t CRenderAuxGeomD3D : : CBufferManager : : fill ( buffer_handle_t buf , BUFFER_BIND_TYPE type , const void * data , size_t size ) <nl> + { <nl> + if ( buf ! = ~ 0u ) gcpRendD3D - > m_DevBufMan . Destroy ( buf ) ; <nl> <nl> - DetermineAuxPrimitveFlags ( d3dNumPrimDivider , ePrimType , primType ) ; <nl> + return size ? update ( type , data , size ) : ~ 0u ; <nl> + } <nl> <nl> - / / helpers for DP call <nl> - uint32 initialVBLockOffset ( m_auxGeomSBM . m_curVBIndex ) ; <nl> - uint32 numVerticesWrittenToVB ( 0 ) ; <nl> <nl> - m_renderer . FX_Commit ( ) ; <nl> + CRenderPrimitive & CRenderAuxGeomD3D : : PreparePrimitive ( const SAuxGeomRenderFlags & flags , ERenderPrimitiveType topology , buffer_handle_t vb , buffer_handle_t ib , const Matrix44 & mViewProj ) <nl> + { <nl> + CD3D9Renderer * const __restrict renderer = gcpRendD3D ; <nl> <nl> - / / process each entry <nl> - for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( itBegin ) ; it ! = itEnd ; + + it ) <nl> - { <nl> - / / get current push buffer entry <nl> - const CAuxGeomCB : : SAuxPushBufferEntry * curPBEntry ( * it ) ; <nl> + CStandardGraphicsPipeline : : SViewInfo viewInfo [ 2 ] ; <nl> + const int32 viewInfoCount = renderer - > GetGraphicsPipeline ( ) . GetViewInfo ( viewInfo ) ; <nl> <nl> - / / number of vertices to copy <nl> - uint32 verticesToCopy ( curPBEntry - > m_numVertices ) ; <nl> - uint32 verticesCopied ( 0 ) ; <nl> + const bool bReverseDepth = ( viewInfo [ 0 ] . flags & CStandardGraphicsPipeline : : SViewInfo : : eFlags_ReverseDepth ) ! = 0 ; <nl> + int32 gsFunc = bReverseDepth ? GS_DEPTHFUNC_GEQUAL : GS_DEPTHFUNC_LEQUAL ; <nl> <nl> - / / stream vertex data <nl> - while ( verticesToCopy > 0 ) <nl> - { <nl> - / / number of vertices which fit into current vb <nl> - uint32 maxVerticesInThisBatch ( e_auxGeomVBSize - m_auxGeomSBM . m_curVBIndex ) ; <nl> <nl> - / / round down to previous multiple of " d3dNumPrimDivider " <nl> - maxVerticesInThisBatch - = maxVerticesInThisBatch % d3dNumPrimDivider ; <nl> + const SViewport & vp = viewInfo [ 0 ] . viewport ; <nl> + D3DViewPort viewport = { float ( vp . nX ) , float ( vp . nY ) , float ( vp . nX ) + vp . nWidth , float ( vp . nY ) + vp . nHeight , vp . fMinZ , vp . fMaxZ } ; <nl> <nl> - / / still enough space to feed data in the current vb <nl> - if ( maxVerticesInThisBatch > 0 ) <nl> - { <nl> - / / compute amount of vertices to move in this batch <nl> - uint32 toCopy ( verticesToCopy > maxVerticesInThisBatch ? maxVerticesInThisBatch : verticesToCopy ) ; <nl> <nl> - / / determine lock flags <nl> - D3D11_MAP mapFlags ( D3D11_MAP_WRITE_NO_OVERWRITE_VB ) ; <nl> - if ( false ! = m_auxGeomSBM . m_discardVB ) <nl> - { <nl> - m_auxGeomSBM . m_discardVB = false ; <nl> - mapFlags = D3D11_MAP_WRITE_DISCARD_VB ; <nl> - } <nl> + m_geomPass . ClearPrimitives ( ) ; <nl> + m_geomPass . SetViewport ( viewport ) ; <nl> <nl> - CDeviceManager : : UploadContents < false > ( m_pAuxGeomVB , 0 , m_auxGeomSBM . m_curVBIndex * sizeof ( SAuxVertex ) , toCopy * sizeof ( SAuxVertex ) , mapFlags , & auxVertexBuffer [ curPBEntry - > m_vertexOffs + verticesCopied ] ) ; <nl> + m_geomPass . SetRenderTarget ( 0 , renderer - > GetBackBufferTexture ( ) ) ; <nl> + m_geomPass . SetDepthTarget ( & renderer - > m_DepthBufferOrig ) ; <nl> <nl> - / / update accumulators and buffer indices <nl> - verticesCopied + = toCopy ; <nl> - verticesToCopy - = toCopy ; <nl> + auto & prim = m_geomPrimitiveCache [ topology ] ; <nl> <nl> - m_auxGeomSBM . m_curVBIndex + = toCopy ; <nl> - numVerticesWrittenToVB + = toCopy ; <nl> - } <nl> - else <nl> - { <nl> - / / not enough space in vb for ( remainder of ) current push buffer entry <nl> - if ( numVerticesWrittenToVB > 0 ) <nl> - { <nl> - / / commit batch <nl> - assert ( 0 = = numVerticesWrittenToVB % d3dNumPrimDivider ) ; <nl> - if ( streamsBound ) <nl> - m_renderer . FX_DrawPrimitive ( ePrimType , initialVBLockOffset , numVerticesWrittenToVB ) ; <nl> - } <nl> + prim . SetFlags ( CRenderPrimitive : : eFlags_ReflectConstantBuffersFromShader ) ; <nl> <nl> - / / request a DISCARD lock of vb in the next run <nl> - m_auxGeomSBM . DiscardVB ( ) ; <nl> - initialVBLockOffset = m_auxGeomSBM . m_curVBIndex ; <nl> - numVerticesWrittenToVB = 0 ; <nl> - } <nl> - } <nl> + { <nl> + static CCryNameTSCRC tGeom ( " AuxGeometry " ) ; <nl> + <nl> + prim . SetTechnique ( m_pAuxGeomShader , tGeom , 0 ) ; <nl> } <nl> <nl> - if ( numVerticesWrittenToVB > 0 ) <nl> + if ( flags . GetDepthTestFlag ( ) = = e_DepthTestOff ) gsFunc | = GS_NODEPTHTEST ; <nl> + if ( flags . GetDepthWriteFlag ( ) = = e_DepthWriteOn ) gsFunc | = GS_DEPTHWRITE ; <nl> + <nl> + if ( flags . GetFillMode ( ) = = e_FillModeWireframe ) gsFunc | = GS_WIREFRAME ; <nl> + <nl> + <nl> + switch ( flags . GetAlphaBlendMode ( ) ) <nl> { <nl> - / / commit batch <nl> - assert ( 0 = = numVerticesWrittenToVB % d3dNumPrimDivider ) ; <nl> + case e_AlphaBlended : gsFunc | = GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA ; break ; <nl> + case e_AlphaAdditive : gsFunc | = GS_BLSRC_ONE | GS_BLDST_ONE ; <nl> + } <nl> <nl> - if ( streamsBound ) <nl> - m_renderer . FX_DrawPrimitive ( ePrimType , initialVBLockOffset , numVerticesWrittenToVB ) ; <nl> + switch ( flags . GetCullMode ( ) ) <nl> + { <nl> + case e_CullModeFront : prim . SetCullMode ( eCULL_Front ) ; break ; <nl> + case e_CullModeNone : prim . SetCullMode ( eCULL_None ) ; break ; <nl> + default : prim . SetCullMode ( eCULL_Back ) ; <nl> } <nl> + <nl> + prim . SetRenderState ( gsFunc ) ; <nl> + prim . SetDrawTopology ( topology ) ; <nl> + <nl> + prim . SetCullMode ( eCULL_None ) ; <nl> + <nl> + prim . SetCustomVertexStream ( vb , eVF_P3F_C4B_T2F , sizeof ( SVF_P3F_C4B_T2F ) ) ; <nl> + prim . SetCustomIndexStream ( ib , indexbuffer_type < vtx_idx > : : type ) ; <nl> + <nl> + / / prim . SetTexture ( 0 , CTexture : : GetByID ( pfProxy - > GetTexture ( ) ) ) ; <nl> + / / prim . SetSampler ( 0 , CTexture : : GetTexState ( STexState ( FILTER_LINEAR , true ) ) ) ; <nl> + <nl> + static CCryNameR matViewProjName ( " matViewProj " ) ; <nl> + <nl> + auto & constantManager = prim . GetConstantManager ( ) ; <nl> + <nl> + constantManager . BeginNamedConstantUpdate ( ) ; <nl> + constantManager . SetNamedConstantArray ( matViewProjName , ( Vec4 * ) & mViewProj , 4 , eHWSC_Vertex ) ; <nl> + constantManager . EndNamedConstantUpdate ( ) ; <nl> + <nl> + prim . ResetDrawInfo ( ) ; <nl> + <nl> + return prim ; <nl> } <nl> <nl> - void CRenderAuxGeomD3D : : DrawAuxIndexedPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const CAuxGeomCB : : EPrimType & primType ) <nl> + void CRenderAuxGeomD3D : : DrawAuxPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) <nl> { <nl> - assert ( CAuxGeomCB : : e_LineListInd = = primType | | CAuxGeomCB : : e_TriListInd = = primType ) ; <nl> + ERenderPrimitiveType topology ; <nl> <nl> - HRESULT hr ( S_OK ) ; <nl> + const SAuxGeomRenderFlags & flags = ( * itBegin ) - > m_renderFlags ; <nl> + CAuxGeomCB : : EPrimType primType ( CAuxGeomCB : : GetPrimType ( flags ) ) ; <nl> + <nl> + if ( primType = = CAuxGeomCB : : e_LineList ) topology = eptLineList ; <nl> + else if ( primType = = CAuxGeomCB : : e_TriList ) topology = eptTriangleList ; <nl> + else if ( primType = = CAuxGeomCB : : e_PtList ) topology = eptPointList ; <nl> + else <nl> + { <nl> + assert ( false ) ; <nl> + return ; <nl> + } <nl> <nl> - / / bind vertex and index streams and set vertex declaration <nl> - bool streamsBound = BindStreams ( eVF_P3F_C4B_T2F , m_pAuxGeomVB , m_pAuxGeomIB ) ; <nl> <nl> - / / get aux vertex and index buffer <nl> - const CAuxGeomCB : : AuxVertexBuffer & auxVertexBuffer ( GetAuxVertexBuffer ( ) ) ; <nl> - const CAuxGeomCB : : AuxIndexBuffer & auxIndexBuffer ( GetAuxIndexBuffer ( ) ) ; <nl> - CAuxGeomCB : : AuxIndexBuffer auxIndexBufferJoined ( auxIndexBuffer . size ( ) ) ; <nl> + CRenderPrimitive & prim = PreparePrimitive ( flags , topology , m_bufman . GetVB ( ) , ~ 0u , mViewProj ) ; <nl> <nl> - / / determine flags for prim type <nl> - uint32 d3dNumPrimDivider ; <nl> - ERenderPrimitiveType ePrimType ; <nl> - DetermineAuxPrimitveFlags ( d3dNumPrimDivider , ePrimType , primType ) ; <nl> + auto & instance = prim . m_instances . front ( ) ; <nl> <nl> - / / helpers for DP call <nl> - uint32 initialVBLockOffset ( m_auxGeomSBM . m_curVBIndex ) ; <nl> - uint32 numVerticesWrittenToVB ( 0 ) ; <nl> - uint32 initialIBLockOffset ( m_auxGeomSBM . m_curIBIndex ) ; <nl> - uint32 numIndicesWrittenToIB ( 0 ) ; <nl> + instance . vertexBaseOffset = 0 ; <nl> + instance . vertexOrIndexOffset = ( * itBegin ) - > m_vertexOffs ; <nl> + instance . vertexOrIndexCount = ( * itBegin ) - > m_numVertices ; <nl> <nl> - m_renderer . FX_Commit ( ) ; <nl> + prim . m_instances . resize ( 1 ) ; <nl> <nl> - / / process each entry <nl> - for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( itBegin ) ; it ! = itEnd ; ) <nl> + for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( itBegin ) ; + + it ! = itEnd ; ) <nl> { <nl> - / / get current push buffer entry <nl> - const CAuxGeomCB : : SAuxPushBufferEntry * curPBEntry ( * it ) ; <nl> + SCompiledRenderPrimitive : : SInstanceInfo instance ; <nl> <nl> - / / process a push buffer entry if it can fit at all ( otherwise silently skip it ) <nl> - if ( e_auxGeomVBSize > = curPBEntry - > m_numVertices & & e_auxGeomIBSize > = curPBEntry - > m_numIndices ) <nl> - { <nl> - / / check if push buffer still fits into current buffer <nl> - if ( e_auxGeomVBSize > = m_auxGeomSBM . m_curVBIndex + curPBEntry - > m_numVertices & & e_auxGeomIBSize > = m_auxGeomSBM . m_curIBIndex + curPBEntry - > m_numIndices ) <nl> - { <nl> - / / move index data of this entry ( modify indices to match VB insert location ) <nl> - for ( uint32 i ( 0 ) ; i < curPBEntry - > m_numIndices ; + + i ) <nl> - { <nl> - / / cppcheck - suppress nullPointer <nl> - auxIndexBufferJoined [ curPBEntry - > m_indexOffs + i ] = numVerticesWrittenToVB + auxIndexBuffer [ curPBEntry - > m_indexOffs + i ] ; <nl> - } <nl> + instance . vertexBaseOffset = 0 ; <nl> + instance . vertexOrIndexOffset = ( * it ) - > m_vertexOffs ; <nl> + instance . vertexOrIndexCount = ( * it ) - > m_numVertices ; <nl> <nl> - / / determine lock vb flags <nl> - D3D11_MAP mapFlags ( D3D11_MAP_WRITE_NO_OVERWRITE_VB ) ; <nl> - if ( m_auxGeomSBM . m_discardVB ) <nl> - { <nl> - m_auxGeomSBM . m_discardVB = false ; <nl> - mapFlags = D3D11_MAP_WRITE_DISCARD_VB ; <nl> - } <nl> + prim . m_instances . push_back ( instance ) ; <nl> + } <nl> <nl> - CDeviceManager : : UploadContents < false > ( m_pAuxGeomVB , 0 , m_auxGeomSBM . m_curVBIndex * sizeof ( SAuxVertex ) , curPBEntry - > m_numVertices * sizeof ( SAuxVertex ) , mapFlags , & auxVertexBuffer [ curPBEntry - > m_vertexOffs ] ) ; <nl> + if ( ! m_geomPass . AddPrimitive ( & prim ) ) <nl> + { <nl> + return ; <nl> + } <nl> <nl> - / / determine lock ib flags <nl> - mapFlags = D3D11_MAP_WRITE_NO_OVERWRITE_IB ; <nl> - if ( m_auxGeomSBM . m_discardIB ) <nl> - { <nl> - m_auxGeomSBM . m_discardIB = false ; <nl> - mapFlags = D3D11_MAP_WRITE_DISCARD_IB ; <nl> - } <nl> + m_geomPass . Execute ( ) ; <nl> + } <nl> <nl> - CDeviceManager : : UploadContents < false > ( m_pAuxGeomIB , 0 , m_auxGeomSBM . m_curIBIndex * sizeof ( vtx_idx ) , curPBEntry - > m_numIndices * sizeof ( vtx_idx ) , mapFlags , & auxIndexBufferJoined [ curPBEntry - > m_indexOffs ] ) ; <nl> + void CRenderAuxGeomD3D : : DrawAuxIndexedPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) <nl> + { <nl> + ERenderPrimitiveType topology ; <nl> <nl> - / / update buffer indices <nl> - m_auxGeomSBM . m_curVBIndex + = curPBEntry - > m_numVertices ; <nl> - m_auxGeomSBM . m_curIBIndex + = curPBEntry - > m_numIndices ; <nl> + const SAuxGeomRenderFlags & flags = ( * itBegin ) - > m_renderFlags ; <nl> + CAuxGeomCB : : EPrimType primType ( CAuxGeomCB : : GetPrimType ( flags ) ) ; <nl> <nl> - numVerticesWrittenToVB + = curPBEntry - > m_numVertices ; <nl> - numIndicesWrittenToIB + = curPBEntry - > m_numIndices ; <nl> + if ( primType = = CAuxGeomCB : : e_LineListInd ) topology = eptLineList ; <nl> + else if ( primType = = CAuxGeomCB : : e_TriListInd ) topology = eptTriangleList ; <nl> + else <nl> + { <nl> + assert ( false ) ; <nl> + return ; <nl> + } <nl> <nl> - / / advance to next push puffer entry <nl> - + + it ; <nl> - } <nl> - else <nl> - { <nl> - / / push buffer entry currently doesn ' t fit , will be processed in the next iteration when buffers got flushed <nl> - if ( numVerticesWrittenToVB > 0 & & numIndicesWrittenToIB > 0 ) <nl> - { <nl> - / / commit batch <nl> - assert ( 0 = = numIndicesWrittenToIB % d3dNumPrimDivider ) ; <nl> - if ( streamsBound ) <nl> - m_renderer . FX_DrawIndexedPrimitive ( ePrimType , initialVBLockOffset , 0 , numVerticesWrittenToVB , initialIBLockOffset , numIndicesWrittenToIB ) ; <nl> - } <nl> + CRenderPrimitive & prim = PreparePrimitive ( flags , topology , m_bufman . GetVB ( ) , m_bufman . GetIB ( ) , mViewProj ) ; <nl> <nl> - / / request a DISCARD lock / don ' t advance iterator ! <nl> - m_auxGeomSBM . DiscardVB ( ) ; <nl> - initialVBLockOffset = m_auxGeomSBM . m_curVBIndex ; <nl> - numVerticesWrittenToVB = 0 ; <nl> + auto & instance = prim . m_instances . front ( ) ; <nl> <nl> - m_auxGeomSBM . DiscardIB ( ) ; <nl> - initialIBLockOffset = m_auxGeomSBM . m_curIBIndex ; <nl> - numIndicesWrittenToIB = 0 ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / push buffer entry too big for dedicated vb / ib buffer <nl> - / / advance to next push puffer entry <nl> - assert ( 0 ) ; <nl> - iLog - > Log ( " ERROR : CD3DRenderAuxGeom : : DrawAuxIndexedPrimitives ( ) - Auxiliary geometry too big to render ! " ) ; <nl> - + + it ; <nl> - } <nl> + instance . vertexBaseOffset = ( * itBegin ) - > m_vertexOffs ; <nl> + instance . vertexOrIndexOffset = ( * itBegin ) - > m_indexOffs ; <nl> + instance . vertexOrIndexCount = ( * itBegin ) - > m_numIndices ; <nl> + <nl> + prim . m_instances . resize ( 1 ) ; <nl> + <nl> + for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( itBegin ) ; + + it ! = itEnd ; ) <nl> + { <nl> + SCompiledRenderPrimitive : : SInstanceInfo instance ; <nl> + <nl> + instance . vertexBaseOffset = ( * it ) - > m_vertexOffs ; <nl> + instance . vertexOrIndexOffset = ( * it ) - > m_indexOffs ; <nl> + instance . vertexOrIndexCount = ( * it ) - > m_numIndices ; <nl> + <nl> + prim . m_instances . push_back ( instance ) ; <nl> } <nl> <nl> - if ( numVerticesWrittenToVB > 0 & & numIndicesWrittenToIB > 0 ) <nl> + if ( ! m_geomPass . AddPrimitive ( & prim ) ) <nl> { <nl> - / / commit batch <nl> - assert ( 0 = = numIndicesWrittenToIB % d3dNumPrimDivider ) ; <nl> - if ( streamsBound ) <nl> - m_renderer . FX_DrawIndexedPrimitive ( ePrimType , initialVBLockOffset , 0 , numVerticesWrittenToVB , initialIBLockOffset , numIndicesWrittenToIB ) ; <nl> + return ; <nl> } <nl> + <nl> + m_geomPass . Execute ( ) ; <nl> } <nl> <nl> - void CRenderAuxGeomD3D : : DrawAuxObjects ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd ) <nl> + void CRenderAuxGeomD3D : : DrawAuxObjects ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) <nl> { <nl> CAuxGeomCB : : EAuxDrawObjType objType ( CAuxGeomCB : : GetAuxObjType ( ( * itBegin ) - > m_renderFlags ) ) ; <nl> <nl> void CRenderAuxGeomD3D : : PrepareRendering ( ) <nl> / / reset DrawInFront mode <nl> m_curDrawInFrontMode = e_DrawInFrontOff ; <nl> <nl> - / / reset stream buffer manager <nl> - m_auxGeomSBM . Reset ( ) ; <nl> <nl> / / reset current VB / IB <nl> m_pCurVB = 0 ; <nl> void CRenderAuxGeomD3D : : PrepareRendering ( ) <nl> } <nl> <nl> <nl> - # include < climits > <nl> - <nl> - template < class T = vtx_idx , int size = sizeof ( T ) * CHAR_BIT > struct indexbuffer_type ; <nl> - <nl> - template < class T > struct indexbuffer_type < T , 16 > { static const RenderIndexType type = Index16 ; } ; <nl> - template < class T > struct indexbuffer_type < T , 32 > { static const RenderIndexType type = Index32 ; } ; <nl> - <nl> bool CRenderAuxGeomD3D : : BindStreams ( EVertexFormat newVertexFormat , D3DVertexBuffer * pNewVB , D3DIndexBuffer * pNewIB ) <nl> { <nl> / / set vertex declaration <nl> bool CRenderAuxGeomD3D : : BindStreams ( EVertexFormat newVertexFormat , D3DVertexBuff <nl> return SUCCEEDED ( hr ) ; <nl> } <nl> <nl> - void CRenderAuxGeomD3D : : SetShader ( const SAuxGeomRenderFlags & renderFlags ) <nl> + void CRenderAuxGeomD3D : : Prepare ( const SAuxGeomRenderFlags & renderFlags , Matrix44A & mat ) <nl> { <nl> - if ( 0 = = m_pAuxGeomShader ) <nl> - { <nl> - / / allow invalid file access for this shader because it shouldn ' t be used in the final build anyway <nl> - CDebugAllowFileAccess ignoreInvalidFileAccess ; <nl> - m_pAuxGeomShader = m_renderer . m_cEF . mfForName ( " AuxGeom " , EF_SYSTEM ) ; <nl> - assert ( 0 ! = m_pAuxGeomShader ) ; <nl> - } <nl> - <nl> - if ( 0 ! = m_pAuxGeomShader ) <nl> - { <nl> - bool dirty ( 0 ! = ( m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_PersFlags & ( RBPF_FP_DIRTY | RBPF_FP_MATRIXDIRTY ) ) ) ; <nl> - if ( false ! = dirty ) <nl> - { <nl> - / / NOTE : dirty flags are either set when marking matrices as dirty or setting EF_ColorOp in AdjustRenderStates <nl> - m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_PersFlags & = ~ RBPF_FP_DIRTY | RBPF_FP_MATRIXDIRTY ; <nl> - m_renderer . m_RP . m_ObjFlags & = ~ FOB_TRANS_MASK ; <nl> - m_renderer . m_RP . m_pCurObject = m_renderer . m_RP . m_pIdendityRenderObject ; <nl> - m_renderer . m_RP . m_FlagsShader_LT = m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_eCurColorOp | ( m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_eCurAlphaOp < < 8 ) | <nl> - ( m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_eCurColorArg < < 16 ) | ( m_renderer . m_RP . m_TI [ m_renderer . m_RP . m_nProcessThreadID ] . m_eCurAlphaArg < < 24 ) ; <nl> - } <nl> - <nl> - EAuxGeomPublicRenderflags_DrawInFrontMode newDrawInFrontMode ( renderFlags . GetDrawInFrontMode ( ) ) ; <nl> - CAuxGeomCB : : EPrimType newPrimType ( CAuxGeomCB : : GetPrimType ( renderFlags ) ) ; <nl> - <nl> - if ( false ! = dirty | | m_pAuxGeomShader ! = m_renderer . m_RP . m_pShader | | m_curDrawInFrontMode ! = newDrawInFrontMode | | m_curPrimType ! = newPrimType ) <nl> - { <nl> - if ( CAuxGeomCB : : e_Obj ! = newPrimType ) <nl> - { <nl> - static CCryNameTSCRC techName ( " AuxGeometry " ) ; <nl> - m_pAuxGeomShader - > FXSetTechnique ( techName ) ; <nl> - m_pAuxGeomShader - > FXBegin ( & m_renderer . m_RP . m_nNumRendPasses , FEF_DONTSETTEXTURES | FEF_DONTSETSTATES ) ; <nl> - m_pAuxGeomShader - > FXBeginPass ( 0 ) ; <nl> - <nl> - static CCryNameR matViewProjName ( " matViewProj " ) ; <nl> - if ( e_DrawInFrontOn = = renderFlags . GetDrawInFrontMode ( ) & & e_Mode3D = = renderFlags . GetMode2D3DFlag ( ) ) <nl> - { <nl> - Matrix44A matScale ( Matrix34 : : CreateScale ( Vec3 ( 0 . 999f , 0 . 999f , 0 . 999f ) ) ) ; <nl> - <nl> - Matrix44A matViewScaleProjT ; <nl> - if ( HasWorldMatrix ( ) ) <nl> - { <nl> - matViewScaleProjT = Matrix44A ( GetAuxWorldMatrix ( m_curWorldMatrixIdx ) ) . GetTransposed ( ) * GetCurrentView ( ) * matScale ; <nl> - } <nl> - else <nl> - { <nl> - matViewScaleProjT = GetCurrentView ( ) * matScale ; <nl> - } <nl> - matViewScaleProjT = matViewScaleProjT * GetCurrentProj ( ) ; <nl> - matViewScaleProjT = matViewScaleProjT . GetTransposed ( ) ; <nl> - m_pAuxGeomShader - > FXSetVSFloat ( matViewProjName , alias_cast < Vec4 * > ( & matViewScaleProjT ) , 4 ) ; <nl> - m_curDrawInFrontMode = e_DrawInFrontOn ; <nl> - } <nl> - else <nl> - { <nl> - Matrix44A matViewProjT ; <nl> - if ( HasWorldMatrix ( ) ) <nl> - { <nl> - matViewProjT = Matrix44 ( GetAuxWorldMatrix ( m_curWorldMatrixIdx ) ) . GetTransposed ( ) * * m_matrices . m_pCurTransMat ; <nl> - matViewProjT = matViewProjT . GetTransposed ( ) ; <nl> - } <nl> - else <nl> - { <nl> - matViewProjT = m_matrices . m_pCurTransMat - > GetTransposed ( ) ; <nl> - } <nl> - m_pAuxGeomShader - > FXSetVSFloat ( matViewProjName , alias_cast < Vec4 * > ( & matViewProjT ) , 4 ) ; <nl> - m_curDrawInFrontMode = e_DrawInFrontOff ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - static CCryNameTSCRC techName ( " AuxGeometryObj " ) ; <nl> - m_pAuxGeomShader - > FXSetTechnique ( techName ) ; <nl> - m_pAuxGeomShader - > FXBegin ( & m_renderer . m_RP . m_nNumRendPasses , FEF_DONTSETTEXTURES | FEF_DONTSETSTATES ) ; <nl> - m_pAuxGeomShader - > FXBeginPass ( 0 ) ; <nl> - <nl> - if ( e_DrawInFrontOn = = renderFlags . GetDrawInFrontMode ( ) & & e_Mode3D = = renderFlags . GetMode2D3DFlag ( ) ) <nl> - { <nl> - m_curDrawInFrontMode = e_DrawInFrontOn ; <nl> - } <nl> - else <nl> - { <nl> - m_curDrawInFrontMode = e_DrawInFrontOff ; <nl> - } <nl> - } <nl> - m_curPrimType = newPrimType ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - m_renderer . FX_SetFPMode ( ) ; <nl> - } <nl> - } <nl> - <nl> - void CRenderAuxGeomD3D : : AdjustRenderStates ( const SAuxGeomRenderFlags & renderFlags ) <nl> - { <nl> - / / init current render states mask <nl> - uint32 curRenderStates ( 0 ) ; <nl> - <nl> / / mode 2D / 3D - - set new transformation matrix <nl> const Matrix44A * pNewTransMat ( & GetCurrentTrans3D ( ) ) ; <nl> - if ( e_Mode2D = = renderFlags . GetMode2D3DFlag ( ) ) <nl> + if ( e_Mode2D = = renderFlags . GetMode2D3DFlag ( ) ) <nl> { <nl> pNewTransMat = & GetCurrentTrans2D ( ) ; <nl> } <nl> - if ( m_matrices . m_pCurTransMat ! = pNewTransMat ) <nl> + if ( m_matrices . m_pCurTransMat ! = pNewTransMat ) <nl> { <nl> m_matrices . m_pCurTransMat = pNewTransMat ; <nl> <nl> void CRenderAuxGeomD3D : : AdjustRenderStates ( const SAuxGeomRenderFlags & renderFlag <nl> m_renderer . EF_DirtyMatrix ( ) ; <nl> } <nl> <nl> - / / set alpha blending mode <nl> - switch ( renderFlags . GetAlphaBlendMode ( ) ) <nl> - { <nl> - case e_AlphaAdditive : <nl> - { <nl> - curRenderStates | = GS_BLSRC_ONE | GS_BLDST_ONE ; <nl> - break ; <nl> - } <nl> - case e_AlphaBlended : <nl> - { <nl> - curRenderStates | = GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA ; <nl> - break ; <nl> - } <nl> - case e_AlphaNone : <nl> - default : <nl> - { <nl> - break ; <nl> - } <nl> - } <nl> + m_curPointSize = ( CAuxGeomCB : : e_PtList = = CAuxGeomCB : : GetPrimType ( renderFlags ) ) ? CAuxGeomCB : : GetPointSize ( renderFlags ) : 1 ; <nl> <nl> - / / set fill mode <nl> - switch ( renderFlags . GetFillMode ( ) ) <nl> - { <nl> - case e_FillModeWireframe : <nl> - { <nl> - curRenderStates | = GS_WIREFRAME ; <nl> - break ; <nl> - } <nl> - case e_FillModeSolid : <nl> - default : <nl> - { <nl> - break ; <nl> - } <nl> - } <nl> + EAuxGeomPublicRenderflags_DrawInFrontMode newDrawInFrontMode ( renderFlags . GetDrawInFrontMode ( ) ) ; <nl> + CAuxGeomCB : : EPrimType newPrimType ( CAuxGeomCB : : GetPrimType ( renderFlags ) ) ; <nl> <nl> - / / set cull mode <nl> - switch ( renderFlags . GetCullMode ( ) ) <nl> - { <nl> - case e_CullModeNone : <nl> - { <nl> - m_renderer . SetCullMode ( R_CULL_NONE ) ; <nl> - break ; <nl> - } <nl> - case e_CullModeFront : <nl> - { <nl> - m_renderer . SetCullMode ( R_CULL_FRONT ) ; <nl> - break ; <nl> - } <nl> - case e_CullModeBack : <nl> - default : <nl> - { <nl> - m_renderer . SetCullMode ( R_CULL_BACK ) ; <nl> - break ; <nl> - } <nl> - } <nl> + m_curDrawInFrontMode = ( e_DrawInFrontOn = = renderFlags . GetDrawInFrontMode ( ) & & e_Mode3D = = renderFlags . GetMode2D3DFlag ( ) ) ? e_DrawInFrontOn : e_DrawInFrontOff ; <nl> <nl> - / / set depth write mode <nl> - switch ( renderFlags . GetDepthWriteFlag ( ) ) <nl> + if ( CAuxGeomCB : : e_Obj ! = newPrimType ) <nl> { <nl> - case e_DepthWriteOff : <nl> + if ( m_curDrawInFrontMode = = e_DrawInFrontOn ) <nl> { <nl> - break ; <nl> - } <nl> - case e_DepthWriteOn : <nl> - default : <nl> - { <nl> - curRenderStates | = GS_DEPTHWRITE ; <nl> - break ; <nl> - } <nl> - } <nl> + Matrix44A matScale ( Matrix34 : : CreateScale ( Vec3 ( 0 . 999f , 0 . 999f , 0 . 999f ) ) ) ; <nl> <nl> - / / set depth test mode <nl> - switch ( renderFlags . GetDepthTestFlag ( ) ) <nl> - { <nl> - case e_DepthTestOff : <nl> - { <nl> - curRenderStates | = GS_NODEPTHTEST ; <nl> - curRenderStates & = ~ GS_DEPTHWRITE ; <nl> - break ; <nl> + mat = GetCurrentView ( ) ; <nl> + <nl> + if ( HasWorldMatrix ( ) ) <nl> + { <nl> + mat = Matrix44A ( GetAuxWorldMatrix ( m_curWorldMatrixIdx ) ) . GetTransposed ( ) * mat ; <nl> + } <nl> + <nl> + mat = mat * matScale ; <nl> + mat = mat * GetCurrentProj ( ) ; <nl> + mat = mat . GetTransposed ( ) ; <nl> } <nl> - case e_DepthTestOn : <nl> - default : <nl> + else <nl> { <nl> - break ; <nl> - } <nl> - } <nl> + mat = * m_matrices . m_pCurTransMat ; <nl> <nl> - / / set point size <nl> - uint8 newPointSize ( m_curPointSize ) ; <nl> - if ( CAuxGeomCB : : e_PtList = = CAuxGeomCB : : GetPrimType ( renderFlags ) ) <nl> - { <nl> - newPointSize = CAuxGeomCB : : GetPointSize ( renderFlags ) ; <nl> - } <nl> - else <nl> - { <nl> - newPointSize = 1 ; <nl> - } <nl> + if ( HasWorldMatrix ( ) ) <nl> + { <nl> + mat = Matrix44 ( GetAuxWorldMatrix ( m_curWorldMatrixIdx ) ) . GetTransposed ( ) * mat ; <nl> + } <nl> <nl> - if ( newPointSize ! = m_curPointSize ) <nl> - { <nl> - assert ( newPointSize > 0 ) ; <nl> - float pointSize ( ( float ) newPointSize ) ; <nl> - assert ( 0 ) ; <nl> - m_curPointSize = newPointSize ; <nl> + mat = mat . GetTransposed ( ) ; <nl> + } <nl> } <nl> <nl> - / / apply states <nl> - m_renderer . FX_SetState ( curRenderStates ) ; <nl> + m_curPrimType = newPrimType ; <nl> <nl> - / / set color operations <nl> - m_renderer . EF_SetColorOp ( eCO_REPLACE , eCO_REPLACE , ( eCA_Diffuse | ( eCA_Diffuse < < 3 ) ) , ( eCA_Diffuse | ( eCA_Diffuse < < 3 ) ) ) ; <nl> } <nl> <nl> + <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , size_t end , bool reset ) <nl> { <nl> if ( ! CV_r_auxGeom ) <nl> return ; <nl> <nl> - PROFILE_LABEL_SCOPE ( " AuxGeom " ) ; <nl> + CStandardGraphicsPipeline : : SwitchFromLegacyPipeline ( ) ; <nl> + <nl> + PROFILE_LABEL_SCOPE ( " AuxGeom_Flush " ) ; <nl> <nl> / / should only be called from render thread <nl> assert ( m_renderer . m_pRT - > IsRenderThread ( ) ) ; <nl> <nl> assert ( data . m_pData ) ; <nl> <nl> + Matrix44 mViewProj ; <nl> + <nl> if ( begin < end ) <nl> { <nl> m_pCurCBRawData = data . m_pData ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> / / get push buffer to process all submitted auxiliary geometries <nl> m_pCurCBRawData - > GetSortedPushBuffer ( begin , end , m_auxSortedPushBuffer ) ; <nl> <nl> - / / process push buffer <nl> - for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( m_auxSortedPushBuffer . begin ( ) ) , itEnd ( m_auxSortedPushBuffer . end ( ) ) ; it ! = itEnd ; ) <nl> + for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( m_auxSortedPushBuffer . begin ( ) ) , itEnd ( m_auxSortedPushBuffer . end ( ) ) ; it ! = itEnd ; ) <nl> { <nl> / / mark current push buffer position <nl> CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itCur ( it ) ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> CAuxGeomCB : : EPrimType primType ( CAuxGeomCB : : GetPrimType ( curRenderFlags ) ) ; <nl> <nl> / / find all entries sharing the same render flags <nl> - while ( true ) <nl> + while ( true ) <nl> { <nl> + + it ; <nl> - if ( ( it = = itEnd ) | | ( ( * it ) - > m_renderFlags ! = curRenderFlags ) | | ( ( * it ) - > m_transMatrixIdx ! = m_curTransMatrixIdx ) | | <nl> - ( ( * it ) - > m_worldMatrixIdx ! = m_curWorldMatrixIdx ) ) <nl> + if ( ( it = = itEnd ) | | ( ( * it ) - > m_renderFlags ! = curRenderFlags ) | | ( ( * it ) - > m_transMatrixIdx ! = m_curTransMatrixIdx ) | | <nl> + ( ( * it ) - > m_worldMatrixIdx ! = m_curWorldMatrixIdx ) ) <nl> { <nl> break ; <nl> } <nl> } <nl> <nl> - / / adjust render states based on current render flags <nl> - AdjustRenderStates ( curRenderFlags ) ; <nl> - <nl> / / prepare thick lines <nl> - if ( CAuxGeomCB : : e_TriList = = primType & & false ! = CAuxGeomCB : : IsThickLine ( curRenderFlags ) ) <nl> + if ( CAuxGeomCB : : e_TriList = = primType & & CAuxGeomCB : : IsThickLine ( curRenderFlags ) ) <nl> { <nl> - if ( e_Mode3D = = curRenderFlags . GetMode2D3DFlag ( ) ) <nl> + if ( e_Mode3D = = curRenderFlags . GetMode2D3DFlag ( ) ) <nl> { <nl> PrepareThickLines3D ( itCur , it ) ; <nl> } <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> PrepareThickLines2D ( itCur , it ) ; <nl> } <nl> } <nl> + } <nl> + <nl> + const CAuxGeomCB : : AuxVertexBuffer & auxVertexBuffer ( GetAuxVertexBuffer ( ) ) ; <nl> + const CAuxGeomCB : : AuxIndexBuffer & auxIndexBuffer ( GetAuxIndexBuffer ( ) ) ; <nl> + <nl> + m_bufman . FillVB ( auxVertexBuffer . data ( ) , auxVertexBuffer . size ( ) * sizeof ( SAuxVertex ) ) ; <nl> + m_bufman . FillIB ( auxIndexBuffer . data ( ) , auxIndexBuffer . size ( ) * sizeof ( vtx_idx ) ) ; <nl> + <nl> + <nl> + / / process push buffer <nl> + for ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator it ( m_auxSortedPushBuffer . begin ( ) ) , itEnd ( m_auxSortedPushBuffer . end ( ) ) ; it ! = itEnd ; ) <nl> + { <nl> + / / mark current push buffer position <nl> + CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itCur ( it ) ; <nl> + <nl> + / / get current render flags <nl> + const SAuxGeomRenderFlags & curRenderFlags ( ( * itCur ) - > m_renderFlags ) ; <nl> + m_curTransMatrixIdx = ( * itCur ) - > m_transMatrixIdx ; <nl> + m_curWorldMatrixIdx = ( * itCur ) - > m_worldMatrixIdx ; <nl> + <nl> + / / get prim type <nl> + CAuxGeomCB : : EPrimType primType ( CAuxGeomCB : : GetPrimType ( curRenderFlags ) ) ; <nl> + <nl> + / / find all entries sharing the same render flags <nl> + while ( true ) <nl> + { <nl> + + + it ; <nl> + if ( ( it = = itEnd ) | | ( ( * it ) - > m_renderFlags ! = curRenderFlags ) | | ( ( * it ) - > m_transMatrixIdx ! = m_curTransMatrixIdx ) | | <nl> + ( ( * it ) - > m_worldMatrixIdx ! = m_curWorldMatrixIdx ) ) <nl> + { <nl> + break ; <nl> + } <nl> + } <nl> <nl> - / / set appropriate shader <nl> - SetShader ( curRenderFlags ) ; <nl> + / / set appropriate rendering data <nl> + Prepare ( curRenderFlags , mViewProj ) ; <nl> + <nl> + if ( ! m_pAuxGeomShader ) <nl> + { <nl> + / / allow invalid file access for this shader because it shouldn ' t be used in the final build anyway <nl> + CDebugAllowFileAccess ignoreInvalidFileAccess ; <nl> + m_pAuxGeomShader = m_renderer . m_cEF . mfForName ( " AuxGeom " , EF_SYSTEM ) ; <nl> + assert ( 0 ! = m_pAuxGeomShader ) ; <nl> + } <nl> <nl> CD3DStereoRenderer & stereoRenderer = gcpRendD3D - > GetS3DRend ( ) ; <nl> const bool bStereoEnabled = stereoRenderer . IsStereoEnabled ( ) ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> if ( bStereoEnabled ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( LEFT_EYE ) ; <nl> - DrawAuxPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxPrimitives ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( LEFT_EYE ) ; <nl> <nl> if ( bStereoSequentialMode ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( RIGHT_EYE ) ; <nl> - DrawAuxPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxPrimitives ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( RIGHT_EYE ) ; <nl> } <nl> } <nl> else <nl> { <nl> - DrawAuxPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxPrimitives ( itCur , it , mViewProj ) ; <nl> } <nl> } <nl> break ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> if ( bStereoEnabled ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( LEFT_EYE ) ; <nl> - DrawAuxIndexedPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxIndexedPrimitives ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( LEFT_EYE ) ; <nl> <nl> if ( bStereoSequentialMode ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( RIGHT_EYE ) ; <nl> - DrawAuxIndexedPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxIndexedPrimitives ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( RIGHT_EYE ) ; <nl> } <nl> } <nl> else <nl> { <nl> - DrawAuxIndexedPrimitives ( itCur , it , primType ) ; <nl> + DrawAuxIndexedPrimitives ( itCur , it , mViewProj ) ; <nl> } <nl> } <nl> break ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> if ( bStereoEnabled ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( LEFT_EYE ) ; <nl> - DrawAuxObjects ( itCur , it ) ; <nl> + DrawAuxObjects ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( LEFT_EYE ) ; <nl> <nl> if ( bStereoSequentialMode ) <nl> { <nl> stereoRenderer . BeginRenderingTo ( RIGHT_EYE ) ; <nl> - DrawAuxObjects ( itCur , it ) ; <nl> + DrawAuxObjects ( itCur , it , mViewProj ) ; <nl> stereoRenderer . EndRenderingTo ( RIGHT_EYE ) ; <nl> } <nl> } <nl> else <nl> { <nl> - DrawAuxObjects ( itCur , it ) ; <nl> + DrawAuxObjects ( itCur , it , mViewProj ) ; <nl> } <nl> } <nl> break ; <nl> void CRenderAuxGeomD3D : : RT_Flush ( SAuxGeomCBRawDataPackaged & data , size_t begin , <nl> m_curWorldMatrixIdx = - 1 ; <nl> } <nl> <nl> + CStandardGraphicsPipeline : : SwitchToLegacyPipeline ( ) ; <nl> + <nl> FlushTextMessages ( data . m_pData - > m_TextMessages , ! reset ) ; <nl> } <nl> <nl> void CRenderAuxGeomD3D : : FlushTextMessages ( CTextMessages & messages , bool reset ) <nl> vColor = pText - > m_Color . toVec4 ( ) * 1 . 0f / 255 . 0f ; <nl> fSize = pText - > m_fFontSize ; <nl> <nl> - <nl> if ( ( nDrawFlags & eDrawText_LegacyBehavior ) = = 0 ) <nl> { <nl> <nl> mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / D3DRenderAuxGeom . h <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / D3DRenderAuxGeom . h <nl> class CRenderAuxGeomD3D : public IRenderAuxGeomImpl <nl> } <nl> <nl> private : <nl> - struct SStreamBufferManager <nl> - { <nl> - public : <nl> - SStreamBufferManager ( ) ; <nl> - void Reset ( ) ; <nl> - void DiscardVB ( ) ; <nl> - void DiscardIB ( ) ; <nl> - <nl> - public : <nl> - bool m_discardVB ; <nl> - uint32 m_curVBIndex ; <nl> - bool m_discardIB ; <nl> - uint32 m_curIBIndex ; <nl> - } ; <nl> - <nl> struct SDrawObjMesh <nl> { <nl> SDrawObjMesh ( ) <nl> class CRenderAuxGeomD3D : public IRenderAuxGeomImpl <nl> <nl> gRenDev - > GetThreadIDs ( mainThreadID , renderThreadID ) ; <nl> <nl> - if ( tid = = renderThreadID ) pAuxGeomCB = new CAuxGeomCB ( pRenderAuxGeomImpl ) ; <nl> - else pAuxGeomCB = new CAuxGeomCBWorkerThread ( pRenderAuxGeomImpl ) ; <nl> + if ( tid = = renderThreadID ) pAuxGeomCB = new CAuxGeomCB ( pRenderAuxGeomImpl ) ; <nl> + else pAuxGeomCB = new CAuxGeomCBWorkerThread ( pRenderAuxGeomImpl ) ; <nl> <nl> m_rwlLocal . WLock ( ) ; <nl> m_auxJobMap . insert ( AUXJobMap : : value_type ( jobID , pAuxGeomCB ) ) ; <nl> class CRenderAuxGeomD3D : public IRenderAuxGeomImpl <nl> private : <nl> CRenderAuxGeomD3D ( CD3D9Renderer & renderer ) ; <nl> void DetermineAuxPrimitveFlags ( uint32 & d3dNumPrimDivider , ERenderPrimitiveType & d3dPrim , CAuxGeomCB : : EPrimType primType ) const ; <nl> - void DrawAuxPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const CAuxGeomCB : : EPrimType & primType ) ; <nl> - void DrawAuxIndexedPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const CAuxGeomCB : : EPrimType & primType ) ; <nl> - void DrawAuxObjects ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd ) ; <nl> + <nl> + CRenderPrimitive & PreparePrimitive ( const SAuxGeomRenderFlags & flags , ERenderPrimitiveType topology , buffer_handle_t vb , buffer_handle_t ib , const Matrix44 & mViewProj ) ; <nl> + <nl> + void DrawAuxPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) ; <nl> + void DrawAuxIndexedPrimitives ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) ; <nl> + void DrawAuxObjects ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd , const Matrix44 & mViewProj ) ; <nl> <nl> void PrepareThickLines2D ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd ) ; <nl> void PrepareThickLines3D ( CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itBegin , CAuxGeomCB : : AuxSortedPushBuffer : : const_iterator itEnd ) ; <nl> <nl> void PrepareRendering ( ) ; <nl> - void SetShader ( const SAuxGeomRenderFlags & renderFlags ) ; <nl> - void AdjustRenderStates ( const SAuxGeomRenderFlags & renderFlags ) ; <nl> + void Prepare ( const SAuxGeomRenderFlags & renderFlags , Matrix44A & mat ) ; <nl> bool BindStreams ( EVertexFormat newVertexFormat , ID3D11Buffer * pNewVB , ID3D11Buffer * pNewIB ) ; <nl> <nl> template < typename TMeshFunc > <nl> class CRenderAuxGeomD3D : public IRenderAuxGeomImpl <nl> const Matrix34 & GetAuxWorldMatrix ( int idx ) const ; <nl> <nl> private : <nl> - CD3D9Renderer & m_renderer ; <nl> <nl> - ID3D11Buffer * m_pAuxGeomVB ; <nl> - ID3D11Buffer * m_pAuxGeomIB ; <nl> + class CBufferManager <nl> + { <nl> + buffer_handle_t vbAux = ~ 0u ; <nl> + buffer_handle_t ibAux = ~ 0u ; <nl> + <nl> + static buffer_handle_t fill ( buffer_handle_t buf , BUFFER_BIND_TYPE type , const void * data , size_t size ) ; <nl> + static buffer_handle_t update ( BUFFER_BIND_TYPE type , const void * data , size_t size ) ; <nl> + <nl> + public : <nl> + ~ CBufferManager ( ) ; <nl> + <nl> + void FillVB ( const void * src , size_t size ) { vbAux = fill ( vbAux , BBT_VERTEX_BUFFER , src , size ) ; } <nl> + void FillIB ( const void * src , size_t size ) { ibAux = fill ( ibAux , BBT_INDEX_BUFFER , src , size ) ; } <nl> <nl> + buffer_handle_t GetVB ( ) { return vbAux ; } <nl> + buffer_handle_t GetIB ( ) { return ibAux ; } <nl> + } ; <nl> + <nl> + CD3D9Renderer & m_renderer ; <nl> ID3D11Buffer * m_pCurVB ; <nl> ID3D11Buffer * m_pCurIB ; <nl> <nl> - SStreamBufferManager m_auxGeomSBM ; <nl> + CBufferManager m_bufman ; <nl> + CPrimitiveRenderPass m_geomPass ; <nl> + std : : map < ERenderPrimitiveType , CRenderPrimitive > m_geomPrimitiveCache ; <nl> <nl> uint32 m_wndXRes ; <nl> uint32 m_wndYRes ; <nl> class CRenderAuxGeomD3D : public IRenderAuxGeomImpl <nl> SDrawObjMesh m_cylinderObj [ e_auxObjNumLOD ] ; <nl> } ; <nl> <nl> - inline <nl> - CRenderAuxGeomD3D : : SStreamBufferManager : : SStreamBufferManager ( ) <nl> - : m_discardVB ( true ) <nl> - , m_curVBIndex ( 0 ) <nl> - , m_discardIB ( true ) <nl> - , m_curIBIndex ( 0 ) <nl> - { <nl> - } <nl> - <nl> - inline void <nl> - CRenderAuxGeomD3D : : SStreamBufferManager : : Reset ( ) <nl> - { <nl> - m_discardVB = true ; <nl> - m_curVBIndex = 0 ; <nl> - m_discardIB = true ; <nl> - m_curIBIndex = 0 ; <nl> - } <nl> - <nl> - inline void <nl> - CRenderAuxGeomD3D : : SStreamBufferManager : : DiscardVB ( ) <nl> - { <nl> - m_discardVB = true ; <nl> - m_curVBIndex = 0 ; <nl> - } <nl> - <nl> - inline void <nl> - CRenderAuxGeomD3D : : SStreamBufferManager : : DiscardIB ( ) <nl> - { <nl> - m_discardIB = true ; <nl> - m_curIBIndex = 0 ; <nl> - } <nl> <nl> inline void CRenderAuxGeomD3D : : DetermineAuxPrimitveFlags ( uint32 & d3dNumPrimDivider , ERenderPrimitiveType & ePrimType , CAuxGeomCB : : EPrimType primType ) const <nl> { <nl> mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / GraphicsPipeline / StandardGraphicsPipeline . h <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / GraphicsPipeline / StandardGraphicsPipeline . h <nl> class CStandardGraphicsPipeline : public CGraphicsPipeline <nl> void RenderScreenSpaceSSS ( CTexture * pIrradianceTex ) ; <nl> void RenderPostAA ( ) ; <nl> <nl> - void SwitchToLegacyPipeline ( ) ; <nl> - void SwitchFromLegacyPipeline ( ) ; <nl> + static void SwitchToLegacyPipeline ( ) ; <nl> + static void SwitchFromLegacyPipeline ( ) ; <nl> <nl> uint32 IncrementNumInvalidDrawcalls ( int count ) { return CryInterlockedAdd ( ( volatile int * ) & m_numInvalidDrawcalls , count ) ; } <nl> uint32 GetNumInvalidDrawcalls ( ) const { return m_numInvalidDrawcalls ; } <nl> | ! XR DEV - 3092 ( Renderer , AuxRenderer ) PSO for Aux generated geometry ( Approved by nicolas ) | CRYTEK/CRYENGINE | 052672bb1e4a91534466dc7e0d25a81039ceda2f | 2016-11-14T12:43:02Z |
new file mode 100644 <nl> index 00000000000 . . ca50470e664 <nl> mmm / dev / null <nl> ppp b / examples / csharp / helloworld - from - cli / Greeter . sln <nl> <nl> + <nl> + Microsoft Visual Studio Solution File , Format Version 12 . 00 <nl> + # Visual Studio 15 <nl> + VisualStudioVersion = 15 . 0 . 26228 . 4 <nl> + MinimumVisualStudioVersion = 10 . 0 . 40219 . 1 <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Greeter " , " Greeter \ Greeter . csproj " , " { 13B6DFC8 - F5F6 - 4CC2 - 99DF - 57A7CF042033 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " GreeterClient " , " GreeterClient \ GreeterClient . csproj " , " { B754FB02 - D501 - 4308 - 8B89 - 33AB7119C80D } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " GreeterServer " , " GreeterServer \ GreeterServer . csproj " , " { DDBFF994 - E076 - 43AD - B18D - 049DFC1B670C } " <nl> + EndProject <nl> + Global <nl> + GlobalSection ( SolutionConfigurationPlatforms ) = preSolution <nl> + Debug | Any CPU = Debug | Any CPU <nl> + Release | Any CPU = Release | Any CPU <nl> + EndGlobalSection <nl> + GlobalSection ( ProjectConfigurationPlatforms ) = postSolution <nl> + { 13B6DFC8 - F5F6 - 4CC2 - 99DF - 57A7CF042033 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 13B6DFC8 - F5F6 - 4CC2 - 99DF - 57A7CF042033 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 13B6DFC8 - F5F6 - 4CC2 - 99DF - 57A7CF042033 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 13B6DFC8 - F5F6 - 4CC2 - 99DF - 57A7CF042033 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { B754FB02 - D501 - 4308 - 8B89 - 33AB7119C80D } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { B754FB02 - D501 - 4308 - 8B89 - 33AB7119C80D } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { B754FB02 - D501 - 4308 - 8B89 - 33AB7119C80D } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { B754FB02 - D501 - 4308 - 8B89 - 33AB7119C80D } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { DDBFF994 - E076 - 43AD - B18D - 049DFC1B670C } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { DDBFF994 - E076 - 43AD - B18D - 049DFC1B670C } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { DDBFF994 - E076 - 43AD - B18D - 049DFC1B670C } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { DDBFF994 - E076 - 43AD - B18D - 049DFC1B670C } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + EndGlobalSection <nl> + GlobalSection ( SolutionProperties ) = preSolution <nl> + HideSolutionNode = FALSE <nl> + EndGlobalSection <nl> + EndGlobal <nl> new file mode 100644 <nl> index 00000000000 . . 6b26be1c9cd <nl> mmm / dev / null <nl> ppp b / examples / csharp / helloworld - from - cli / Greeter / Greeter . csproj <nl> <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < PropertyGroup > <nl> + < AssemblyTitle > Greeter < / AssemblyTitle > <nl> + < TargetFrameworks > netcoreapp1 . 0 < / TargetFrameworks > <nl> + < DebugType > portable < / DebugType > <nl> + < AssemblyName > Greeter < / AssemblyName > <nl> + < PackageId > Greeter < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> + < / PropertyGroup > <nl> + <nl> + < ItemGroup > <nl> + < PackageReference Include = " Google . Protobuf " Version = " 3 . 2 . 0 " / > <nl> + < PackageReference Include = " Google . Protobuf . Tools " Version = " 3 . 2 . 0 " / > <nl> + < PackageReference Include = " Grpc " Version = " 1 . 2 . 2 " / > <nl> + < PackageReference Include = " Grpc . Tools " Version = " 1 . 2 . 2 " / > <nl> + < / ItemGroup > <nl> + <nl> + < / Project > <nl> mmm a / examples / csharp / helloworld - from - cli / Greeter / Helloworld . cs <nl> ppp b / examples / csharp / helloworld - from - cli / Greeter / Helloworld . cs <nl> <nl> namespace Helloworld { <nl> <nl> / / / < summary > Holder for reflection information generated from helloworld . proto < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public static partial class HelloworldReflection { <nl> <nl> # region Descriptor <nl> public static partial class HelloworldReflection { <nl> } <nl> # region Messages <nl> / / / < summary > <nl> - / / / The request message containing the user ' s name . <nl> + / / / The request message containing the user ' s name . <nl> / / / < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> private static readonly pb : : MessageParser < HelloRequest > _parser = new pb : : MessageParser < HelloRequest > ( ( ) = > new HelloRequest ( ) ) ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pb : : MessageParser < HelloRequest > Parser { get { return _parser ; } } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pbr : : MessageDescriptor Descriptor { <nl> get { return global : : Helloworld . HelloworldReflection . Descriptor . MessageTypes [ 0 ] ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> pbr : : MessageDescriptor pb : : IMessage . Descriptor { <nl> get { return Descriptor ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest ( ) { <nl> OnConstruction ( ) ; <nl> } <nl> <nl> partial void OnConstruction ( ) ; <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest ( HelloRequest other ) : this ( ) { <nl> name_ = other . name_ ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest Clone ( ) { <nl> return new HelloRequest ( this ) ; <nl> } <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> / / / < summary > Field number for the " name " field . < / summary > <nl> public const int NameFieldNumber = 1 ; <nl> private string name_ = " " ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Name { <nl> get { return name_ ; } <nl> set { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override bool Equals ( object other ) { <nl> return Equals ( other as HelloRequest ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public bool Equals ( HelloRequest other ) { <nl> if ( ReferenceEquals ( other , null ) ) { <nl> return false ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> return true ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override int GetHashCode ( ) { <nl> int hash = 1 ; <nl> if ( Name . Length ! = 0 ) hash ^ = Name . GetHashCode ( ) ; <nl> return hash ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override string ToString ( ) { <nl> return pb : : JsonFormatter . ToDiagnosticString ( this ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void WriteTo ( pb : : CodedOutputStream output ) { <nl> if ( Name . Length ! = 0 ) { <nl> output . WriteRawTag ( 10 ) ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int CalculateSize ( ) { <nl> int size = 0 ; <nl> if ( Name . Length ! = 0 ) { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> return size ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( HelloRequest other ) { <nl> if ( other = = null ) { <nl> return ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( pb : : CodedInputStream input ) { <nl> uint tag ; <nl> while ( ( tag = input . ReadTag ( ) ) ! = 0 ) { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / The response message containing the greetings <nl> + / / / The response message containing the greetings <nl> / / / < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> private static readonly pb : : MessageParser < HelloReply > _parser = new pb : : MessageParser < HelloReply > ( ( ) = > new HelloReply ( ) ) ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pb : : MessageParser < HelloReply > Parser { get { return _parser ; } } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pbr : : MessageDescriptor Descriptor { <nl> get { return global : : Helloworld . HelloworldReflection . Descriptor . MessageTypes [ 1 ] ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> pbr : : MessageDescriptor pb : : IMessage . Descriptor { <nl> get { return Descriptor ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply ( ) { <nl> OnConstruction ( ) ; <nl> } <nl> <nl> partial void OnConstruction ( ) ; <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply ( HelloReply other ) : this ( ) { <nl> message_ = other . message_ ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply Clone ( ) { <nl> return new HelloReply ( this ) ; <nl> } <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> / / / < summary > Field number for the " message " field . < / summary > <nl> public const int MessageFieldNumber = 1 ; <nl> private string message_ = " " ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Message { <nl> get { return message_ ; } <nl> set { <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override bool Equals ( object other ) { <nl> return Equals ( other as HelloReply ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public bool Equals ( HelloReply other ) { <nl> if ( ReferenceEquals ( other , null ) ) { <nl> return false ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> return true ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override int GetHashCode ( ) { <nl> int hash = 1 ; <nl> if ( Message . Length ! = 0 ) hash ^ = Message . GetHashCode ( ) ; <nl> return hash ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override string ToString ( ) { <nl> return pb : : JsonFormatter . ToDiagnosticString ( this ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void WriteTo ( pb : : CodedOutputStream output ) { <nl> if ( Message . Length ! = 0 ) { <nl> output . WriteRawTag ( 10 ) ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int CalculateSize ( ) { <nl> int size = 0 ; <nl> if ( Message . Length ! = 0 ) { <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> return size ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( HelloReply other ) { <nl> if ( other = = null ) { <nl> return ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( pb : : CodedInputStream input ) { <nl> uint tag ; <nl> while ( ( tag = input . ReadTag ( ) ) ! = 0 ) { <nl> mmm a / examples / csharp / helloworld - from - cli / Greeter / HelloworldGrpc . cs <nl> ppp b / examples / csharp / helloworld - from - cli / Greeter / HelloworldGrpc . cs <nl> <nl> using System ; <nl> using System . Threading ; <nl> using System . Threading . Tasks ; <nl> - using Grpc . Core ; <nl> + using grpc = global : : Grpc . Core ; <nl> <nl> namespace Helloworld { <nl> / / / < summary > <nl> - / / / The greeting service definition . <nl> + / / / The greeting service definition . <nl> / / / < / summary > <nl> - public static class Greeter <nl> + public static partial class Greeter <nl> { <nl> static readonly string __ServiceName = " helloworld . Greeter " ; <nl> <nl> - static readonly Marshaller < global : : Helloworld . HelloRequest > __Marshaller_HelloRequest = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloRequest . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Helloworld . HelloReply > __Marshaller_HelloReply = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloReply . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Helloworld . HelloRequest > __Marshaller_HelloRequest = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloRequest . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Helloworld . HelloReply > __Marshaller_HelloReply = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloReply . Parser . ParseFrom ) ; <nl> <nl> - static readonly Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > __Method_SayHello = new Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > ( <nl> - MethodType . Unary , <nl> + static readonly grpc : : Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > __Method_SayHello = new grpc : : Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > ( <nl> + grpc : : MethodType . Unary , <nl> __ServiceName , <nl> " SayHello " , <nl> __Marshaller_HelloRequest , <nl> public static class Greeter <nl> } <nl> <nl> / / / < summary > Base class for server - side implementations of Greeter < / summary > <nl> - public abstract class GreeterBase <nl> + public abstract partial class GreeterBase <nl> { <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task < global : : Helloworld . HelloReply > SayHello ( global : : Helloworld . HelloRequest request , ServerCallContext context ) <nl> + / / / < param name = " request " > The request received from the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > The response to send back to the client ( wrapped by a task ) . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task < global : : Helloworld . HelloReply > SayHello ( global : : Helloworld . HelloRequest request , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> } <nl> <nl> / / / < summary > Client for Greeter < / summary > <nl> - public class GreeterClient : ClientBase < GreeterClient > <nl> + public partial class GreeterClient : grpc : : ClientBase < GreeterClient > <nl> { <nl> / / / < summary > Creates a new client for Greeter < / summary > <nl> / / / < param name = " channel " > The channel to use to make remote calls . < / param > <nl> - public GreeterClient ( Channel channel ) : base ( channel ) <nl> + public GreeterClient ( grpc : : Channel channel ) : base ( channel ) <nl> { <nl> } <nl> / / / < summary > Creates a new client for Greeter that uses a custom < c > CallInvoker < / c > . < / summary > <nl> / / / < param name = " callInvoker " > The callInvoker to use to make remote calls . < / param > <nl> - public GreeterClient ( CallInvoker callInvoker ) : base ( callInvoker ) <nl> + public GreeterClient ( grpc : : CallInvoker callInvoker ) : base ( callInvoker ) <nl> { <nl> } <nl> / / / < summary > Protected parameterless constructor to allow creation of test doubles . < / summary > <nl> protected GreeterClient ( ClientBaseConfiguration configuration ) : base ( configurat <nl> } <nl> <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return SayHello ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return SayHello ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . BlockingUnaryCall ( __Method_SayHello , null , options , request ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return SayHelloAsync ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return SayHelloAsync ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncUnaryCall ( __Method_SayHello , null , options , request ) ; <nl> } <nl> + / / / < summary > Creates a new instance of client from given < c > ClientBaseConfiguration < / c > . < / summary > <nl> protected override GreeterClient NewInstance ( ClientBaseConfiguration configuration ) <nl> { <nl> return new GreeterClient ( configuration ) ; <nl> protected override GreeterClient NewInstance ( ClientBaseConfiguration configurati <nl> } <nl> <nl> / / / < summary > Creates service definition that can be registered with a server < / summary > <nl> - public static ServerServiceDefinition BindService ( GreeterBase serviceImpl ) <nl> + / / / < param name = " serviceImpl " > An object implementing the server - side handling logic . < / param > <nl> + public static grpc : : ServerServiceDefinition BindService ( GreeterBase serviceImpl ) <nl> { <nl> - return ServerServiceDefinition . CreateBuilder ( ) <nl> + return grpc : : ServerServiceDefinition . CreateBuilder ( ) <nl> . AddMethod ( __Method_SayHello , serviceImpl . SayHello ) . Build ( ) ; <nl> } <nl> <nl> deleted file mode 100644 <nl> index 72254ce73e9 . . 00000000000 <nl> mmm a / examples / csharp / helloworld - from - cli / Greeter / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " title " : " Greeter " , <nl> - " version " : " 1 . 0 . 0 - * " , <nl> - " buildOptions " : { <nl> - " debugType " : " portable " , <nl> - } , <nl> - " dependencies " : { <nl> - " Google . Protobuf " : " 3 . 0 . 0 " , <nl> - " Grpc " : " 1 . 0 . 1 " , <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { <nl> - " System . Runtime " : " " , <nl> - " System . IO " : " " <nl> - } , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . Platforms " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " imports " : " dnxcore50 " <nl> - } <nl> - } <nl> - } <nl> new file mode 100644 <nl> index 00000000000 . . 24cacfc0219 <nl> mmm / dev / null <nl> ppp b / examples / csharp / helloworld - from - cli / GreeterClient / GreeterClient . csproj <nl> <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < PropertyGroup > <nl> + < AssemblyTitle > GreeterClient < / AssemblyTitle > <nl> + < TargetFrameworks > netcoreapp1 . 0 < / TargetFrameworks > <nl> + < DebugType > portable < / DebugType > <nl> + < AssemblyName > GreeterClient < / AssemblyName > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > GreeterClient < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> + < / PropertyGroup > <nl> + <nl> + < ItemGroup > <nl> + < ProjectReference Include = " . . \ Greeter \ Greeter . csproj " / > <nl> + < / ItemGroup > <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index 09e156f68e8 . . 00000000000 <nl> mmm a / examples / csharp / helloworld - from - cli / GreeterClient / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " title " : " GreeterClient " , <nl> - " version " : " 1 . 0 . 0 - * " , <nl> - " buildOptions " : { <nl> - " debugType " : " portable " , <nl> - " emitEntryPoint " : " true " <nl> - } , <nl> - " dependencies " : { <nl> - " Google . Protobuf " : " 3 . 0 . 0 " , <nl> - " Grpc " : " 1 . 0 . 1 " , <nl> - " Greeter " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { <nl> - " System . Runtime " : " " , <nl> - " System . IO " : " " <nl> - } , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . Platforms " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " imports " : " dnxcore50 " <nl> - } <nl> - } <nl> - } <nl> new file mode 100644 <nl> index 00000000000 . . f7980fa7283 <nl> mmm / dev / null <nl> ppp b / examples / csharp / helloworld - from - cli / GreeterServer / GreeterServer . csproj <nl> <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < PropertyGroup > <nl> + < AssemblyTitle > GreeterServer < / AssemblyTitle > <nl> + < TargetFrameworks > netcoreapp1 . 0 < / TargetFrameworks > <nl> + < DebugType > portable < / DebugType > <nl> + < AssemblyName > GreeterServer < / AssemblyName > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > GreeterServer < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> + < / PropertyGroup > <nl> + <nl> + < ItemGroup > <nl> + < ProjectReference Include = " . . \ Greeter \ Greeter . csproj " / > <nl> + < / ItemGroup > <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index 8802fe32657 . . 00000000000 <nl> mmm a / examples / csharp / helloworld - from - cli / GreeterServer / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " title " : " GreeterServer " , <nl> - " version " : " 1 . 0 . 0 - * " , <nl> - " buildOptions " : { <nl> - " debugType " : " portable " , <nl> - " emitEntryPoint " : " true " <nl> - } , <nl> - " dependencies " : { <nl> - " Google . Protobuf " : " 3 . 0 . 0 " , <nl> - " Grpc " : " 1 . 0 . 1 " , <nl> - " Greeter " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { <nl> - " System . Runtime " : " " , <nl> - " System . IO " : " " <nl> - } , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . Platforms " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 1 " <nl> - } <nl> - } , <nl> - " imports " : " dnxcore50 " <nl> - } <nl> - } <nl> - } <nl> mmm a / examples / csharp / helloworld - from - cli / README . md <nl> ppp b / examples / csharp / helloworld - from - cli / README . md <nl> Example projects in this directory depend on the [ Grpc ] ( https : / / www . nuget . org / pa <nl> and [ Google . Protobuf ] ( https : / / www . nuget . org / packages / Google . Protobuf / ) NuGet packages <nl> which have been already added to the project for you . <nl> <nl> - The examples in this directory target . NET 4 . 5 framework , as . NET Core support is <nl> - currently experimental . <nl> - <nl> PREREQUISITES <nl> mmmmmmmmmmmm - <nl> <nl> - - The DotNetCore SDK cli . <nl> - <nl> - - The . NET 4 . 5 framework . <nl> - <nl> - Both are available to download at https : / / www . microsoft . com / net / download <nl> + - The [ . NET Core SDK ] ( https : / / www . microsoft . com / net / core ) . <nl> <nl> BUILD <nl> mmmmmm - <nl> <nl> From the ` examples / csharp / helloworld - from - cli ` directory : <nl> <nl> - - ` dotnet restore ` <nl> + - ` dotnet restore Greeter . sln ` <nl> <nl> - - ` dotnet build * * / project . json ` ( this will automatically download NuGet dependencies ) <nl> + - ` dotnet build Greeter . sln ` <nl> <nl> Try it ! <nl> mmmmmm - <nl> Try it ! <nl> <nl> ` ` ` <nl> > cd GreeterServer <nl> - > dotnet run <nl> + > dotnet run - f netcoreapp1 . 0 <nl> ` ` ` <nl> <nl> - Run the client <nl> <nl> ` ` ` <nl> > cd GreeterClient <nl> - > dotnet run <nl> + > dotnet run - f netcoreapp1 . 0 <nl> ` ` ` <nl> <nl> Tutorial <nl> new file mode 100644 <nl> index 00000000000 . . 0a35b70e088 <nl> mmm / dev / null <nl> ppp b / examples / csharp / helloworld - from - cli / generate_protos . bat <nl> <nl> + @ rem Copyright 2016 , Google Inc . <nl> + @ rem All rights reserved . <nl> + @ rem <nl> + @ rem Redistribution and use in source and binary forms , with or without <nl> + @ rem modification , are permitted provided that the following conditions are <nl> + @ rem met : <nl> + @ rem <nl> + @ rem * Redistributions of source code must retain the above copyright <nl> + @ rem notice , this list of conditions and the following disclaimer . <nl> + @ rem * Redistributions in binary form must reproduce the above <nl> + @ rem copyright notice , this list of conditions and the following disclaimer <nl> + @ rem in the documentation and / or other materials provided with the <nl> + @ rem distribution . <nl> + @ rem * Neither the name of Google Inc . nor the names of its <nl> + @ rem contributors may be used to endorse or promote products derived from <nl> + @ rem this software without specific prior written permission . <nl> + @ rem <nl> + @ rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + @ rem " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + @ rem LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + @ rem A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + @ rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + @ rem SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + @ rem LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + @ rem DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + @ rem THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + @ rem ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + @ rem OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + @ rem Generate the C # code for . proto files <nl> + <nl> + setlocal <nl> + <nl> + @ rem enter this directory <nl> + cd / d % ~ dp0 <nl> + <nl> + set PROTOC = % UserProfile % \ . nuget \ packages \ Google . Protobuf . Tools \ 3 . 2 . 0 \ tools \ windows_x64 \ protoc . exe <nl> + set PLUGIN = % UserProfile % \ . nuget \ packages \ Grpc . Tools \ 1 . 2 . 2 \ tools \ windows_x64 \ grpc_csharp_plugin . exe <nl> + <nl> + % PROTOC % - I . . / . . / protos - - csharp_out Greeter . . / . . / protos / helloworld . proto - - grpc_out Greeter - - plugin = protoc - gen - grpc = % PLUGIN % <nl> + <nl> + endlocal <nl> deleted file mode 100644 <nl> index f3c33cef6a5 . . 00000000000 <nl> mmm a / examples / csharp / helloworld - from - cli / global . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " sdk " : { <nl> - " version " : " 1 . 0 . 0 - preview2 - 003131 " <nl> - } <nl> - } <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / Greeter / Greeter . csproj <nl> ppp b / examples / csharp / helloworld / Greeter / Greeter . csproj <nl> <nl> < RootNamespace > Greeter < / RootNamespace > <nl> < AssemblyName > Greeter < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > 2669b4f2 < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < DebugSymbols > true < / DebugSymbols > <nl> <nl> < ConsolePause > false < / ConsolePause > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> <nl> < None Include = " packages . config " / > <nl> < / ItemGroup > <nl> < ItemGroup / > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / Greeter / Helloworld . cs <nl> ppp b / examples / csharp / helloworld / Greeter / Helloworld . cs <nl> <nl> namespace Helloworld { <nl> <nl> / / / < summary > Holder for reflection information generated from helloworld . proto < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public static partial class HelloworldReflection { <nl> <nl> # region Descriptor <nl> public static partial class HelloworldReflection { <nl> } <nl> # region Messages <nl> / / / < summary > <nl> - / / / The request message containing the user ' s name . <nl> + / / / The request message containing the user ' s name . <nl> / / / < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> private static readonly pb : : MessageParser < HelloRequest > _parser = new pb : : MessageParser < HelloRequest > ( ( ) = > new HelloRequest ( ) ) ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pb : : MessageParser < HelloRequest > Parser { get { return _parser ; } } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pbr : : MessageDescriptor Descriptor { <nl> get { return global : : Helloworld . HelloworldReflection . Descriptor . MessageTypes [ 0 ] ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> pbr : : MessageDescriptor pb : : IMessage . Descriptor { <nl> get { return Descriptor ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest ( ) { <nl> OnConstruction ( ) ; <nl> } <nl> <nl> partial void OnConstruction ( ) ; <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest ( HelloRequest other ) : this ( ) { <nl> name_ = other . name_ ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloRequest Clone ( ) { <nl> return new HelloRequest ( this ) ; <nl> } <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> / / / < summary > Field number for the " name " field . < / summary > <nl> public const int NameFieldNumber = 1 ; <nl> private string name_ = " " ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Name { <nl> get { return name_ ; } <nl> set { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override bool Equals ( object other ) { <nl> return Equals ( other as HelloRequest ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public bool Equals ( HelloRequest other ) { <nl> if ( ReferenceEquals ( other , null ) ) { <nl> return false ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> return true ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override int GetHashCode ( ) { <nl> int hash = 1 ; <nl> if ( Name . Length ! = 0 ) hash ^ = Name . GetHashCode ( ) ; <nl> return hash ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override string ToString ( ) { <nl> return pb : : JsonFormatter . ToDiagnosticString ( this ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void WriteTo ( pb : : CodedOutputStream output ) { <nl> if ( Name . Length ! = 0 ) { <nl> output . WriteRawTag ( 10 ) ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int CalculateSize ( ) { <nl> int size = 0 ; <nl> if ( Name . Length ! = 0 ) { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> return size ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( HelloRequest other ) { <nl> if ( other = = null ) { <nl> return ; <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( pb : : CodedInputStream input ) { <nl> uint tag ; <nl> while ( ( tag = input . ReadTag ( ) ) ! = 0 ) { <nl> public sealed partial class HelloRequest : pb : : IMessage < HelloRequest > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / The response message containing the greetings <nl> + / / / The response message containing the greetings <nl> / / / < / summary > <nl> - [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ( ) ] <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> private static readonly pb : : MessageParser < HelloReply > _parser = new pb : : MessageParser < HelloReply > ( ( ) = > new HelloReply ( ) ) ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pb : : MessageParser < HelloReply > Parser { get { return _parser ; } } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public static pbr : : MessageDescriptor Descriptor { <nl> get { return global : : Helloworld . HelloworldReflection . Descriptor . MessageTypes [ 1 ] ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> pbr : : MessageDescriptor pb : : IMessage . Descriptor { <nl> get { return Descriptor ; } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply ( ) { <nl> OnConstruction ( ) ; <nl> } <nl> <nl> partial void OnConstruction ( ) ; <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply ( HelloReply other ) : this ( ) { <nl> message_ = other . message_ ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public HelloReply Clone ( ) { <nl> return new HelloReply ( this ) ; <nl> } <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> / / / < summary > Field number for the " message " field . < / summary > <nl> public const int MessageFieldNumber = 1 ; <nl> private string message_ = " " ; <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Message { <nl> get { return message_ ; } <nl> set { <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override bool Equals ( object other ) { <nl> return Equals ( other as HelloReply ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public bool Equals ( HelloReply other ) { <nl> if ( ReferenceEquals ( other , null ) ) { <nl> return false ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> return true ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override int GetHashCode ( ) { <nl> int hash = 1 ; <nl> if ( Message . Length ! = 0 ) hash ^ = Message . GetHashCode ( ) ; <nl> return hash ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public override string ToString ( ) { <nl> return pb : : JsonFormatter . ToDiagnosticString ( this ) ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void WriteTo ( pb : : CodedOutputStream output ) { <nl> if ( Message . Length ! = 0 ) { <nl> output . WriteRawTag ( 10 ) ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int CalculateSize ( ) { <nl> int size = 0 ; <nl> if ( Message . Length ! = 0 ) { <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> return size ; <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( HelloReply other ) { <nl> if ( other = = null ) { <nl> return ; <nl> public sealed partial class HelloReply : pb : : IMessage < HelloReply > { <nl> } <nl> } <nl> <nl> + [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public void MergeFrom ( pb : : CodedInputStream input ) { <nl> uint tag ; <nl> while ( ( tag = input . ReadTag ( ) ) ! = 0 ) { <nl> mmm a / examples / csharp / helloworld / Greeter / HelloworldGrpc . cs <nl> ppp b / examples / csharp / helloworld / Greeter / HelloworldGrpc . cs <nl> <nl> using System ; <nl> using System . Threading ; <nl> using System . Threading . Tasks ; <nl> - using Grpc . Core ; <nl> + using grpc = global : : Grpc . Core ; <nl> <nl> namespace Helloworld { <nl> / / / < summary > <nl> - / / / The greeting service definition . <nl> + / / / The greeting service definition . <nl> / / / < / summary > <nl> - public static class Greeter <nl> + public static partial class Greeter <nl> { <nl> static readonly string __ServiceName = " helloworld . Greeter " ; <nl> <nl> - static readonly Marshaller < global : : Helloworld . HelloRequest > __Marshaller_HelloRequest = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloRequest . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Helloworld . HelloReply > __Marshaller_HelloReply = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloReply . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Helloworld . HelloRequest > __Marshaller_HelloRequest = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloRequest . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Helloworld . HelloReply > __Marshaller_HelloReply = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Helloworld . HelloReply . Parser . ParseFrom ) ; <nl> <nl> - static readonly Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > __Method_SayHello = new Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > ( <nl> - MethodType . Unary , <nl> + static readonly grpc : : Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > __Method_SayHello = new grpc : : Method < global : : Helloworld . HelloRequest , global : : Helloworld . HelloReply > ( <nl> + grpc : : MethodType . Unary , <nl> __ServiceName , <nl> " SayHello " , <nl> __Marshaller_HelloRequest , <nl> public static class Greeter <nl> } <nl> <nl> / / / < summary > Base class for server - side implementations of Greeter < / summary > <nl> - public abstract class GreeterBase <nl> + public abstract partial class GreeterBase <nl> { <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task < global : : Helloworld . HelloReply > SayHello ( global : : Helloworld . HelloRequest request , ServerCallContext context ) <nl> + / / / < param name = " request " > The request received from the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > The response to send back to the client ( wrapped by a task ) . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task < global : : Helloworld . HelloReply > SayHello ( global : : Helloworld . HelloRequest request , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> } <nl> <nl> / / / < summary > Client for Greeter < / summary > <nl> - public class GreeterClient : ClientBase < GreeterClient > <nl> + public partial class GreeterClient : grpc : : ClientBase < GreeterClient > <nl> { <nl> / / / < summary > Creates a new client for Greeter < / summary > <nl> / / / < param name = " channel " > The channel to use to make remote calls . < / param > <nl> - public GreeterClient ( Channel channel ) : base ( channel ) <nl> + public GreeterClient ( grpc : : Channel channel ) : base ( channel ) <nl> { <nl> } <nl> / / / < summary > Creates a new client for Greeter that uses a custom < c > CallInvoker < / c > . < / summary > <nl> / / / < param name = " callInvoker " > The callInvoker to use to make remote calls . < / param > <nl> - public GreeterClient ( CallInvoker callInvoker ) : base ( callInvoker ) <nl> + public GreeterClient ( grpc : : CallInvoker callInvoker ) : base ( callInvoker ) <nl> { <nl> } <nl> / / / < summary > Protected parameterless constructor to allow creation of test doubles . < / summary > <nl> protected GreeterClient ( ClientBaseConfiguration configuration ) : base ( configurat <nl> } <nl> <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return SayHello ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return SayHello ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Helloworld . HelloReply SayHello ( global : : Helloworld . HelloRequest request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . BlockingUnaryCall ( __Method_SayHello , null , options , request ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return SayHelloAsync ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return SayHelloAsync ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / Sends a greeting <nl> + / / / Sends a greeting <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Helloworld . HelloReply > SayHelloAsync ( global : : Helloworld . HelloRequest request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncUnaryCall ( __Method_SayHello , null , options , request ) ; <nl> } <nl> + / / / < summary > Creates a new instance of client from given < c > ClientBaseConfiguration < / c > . < / summary > <nl> protected override GreeterClient NewInstance ( ClientBaseConfiguration configuration ) <nl> { <nl> return new GreeterClient ( configuration ) ; <nl> protected override GreeterClient NewInstance ( ClientBaseConfiguration configurati <nl> } <nl> <nl> / / / < summary > Creates service definition that can be registered with a server < / summary > <nl> - public static ServerServiceDefinition BindService ( GreeterBase serviceImpl ) <nl> + / / / < param name = " serviceImpl " > An object implementing the server - side handling logic . < / param > <nl> + public static grpc : : ServerServiceDefinition BindService ( GreeterBase serviceImpl ) <nl> { <nl> - return ServerServiceDefinition . CreateBuilder ( ) <nl> + return grpc : : ServerServiceDefinition . CreateBuilder ( ) <nl> . AddMethod ( __Method_SayHello , serviceImpl . SayHello ) . Build ( ) ; <nl> } <nl> <nl> mmm a / examples / csharp / helloworld / Greeter / packages . config <nl> ppp b / examples / csharp / helloworld / Greeter / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Tools " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Tools " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / GreeterClient / GreeterClient . csproj <nl> ppp b / examples / csharp / helloworld / GreeterClient / GreeterClient . csproj <nl> <nl> < RootNamespace > GreeterClient < / RootNamespace > <nl> < AssemblyName > GreeterClient < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > 5e942a7d < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < DebugSymbols > true < / DebugSymbols > <nl> <nl> < Externalconsole > true < / Externalconsole > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> <nl> < ItemGroup > <nl> < None Include = " packages . config " / > <nl> < / ItemGroup > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / GreeterClient / packages . config <nl> ppp b / examples / csharp / helloworld / GreeterClient / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / GreeterServer / GreeterServer . csproj <nl> ppp b / examples / csharp / helloworld / GreeterServer / GreeterServer . csproj <nl> <nl> < RootNamespace > GreeterServer < / RootNamespace > <nl> < AssemblyName > GreeterServer < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > 9c7b2963 < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < DebugSymbols > true < / DebugSymbols > <nl> <nl> < Externalconsole > true < / Externalconsole > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> <nl> < ItemGroup > <nl> < None Include = " packages . config " / > <nl> < / ItemGroup > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / GreeterServer / packages . config <nl> ppp b / examples / csharp / helloworld / GreeterServer / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / helloworld / generate_protos . bat <nl> ppp b / examples / csharp / helloworld / generate_protos . bat <nl> setlocal <nl> @ rem enter this directory <nl> cd / d % ~ dp0 <nl> <nl> - set TOOLS_PATH = packages \ Grpc . Tools . 1 . 0 . 1 \ tools \ windows_x86 <nl> + set TOOLS_PATH = packages \ Grpc . Tools . 1 . 2 . 2 \ tools \ windows_x86 <nl> <nl> % TOOLS_PATH % \ protoc . exe - I . . / . . / protos - - csharp_out Greeter . . / . . / protos / helloworld . proto - - grpc_out Greeter - - plugin = protoc - gen - grpc = % TOOLS_PATH % \ grpc_csharp_plugin . exe <nl> <nl> mmm a / examples / csharp / route_guide / RouteGuide / RouteGuide . cs <nl> ppp b / examples / csharp / route_guide / RouteGuide / RouteGuide . cs <nl> public static partial class RouteGuideReflection { <nl> } <nl> # region Messages <nl> / / / < summary > <nl> - / / / Points are represented as latitude - longitude pairs in the E7 representation <nl> - / / / ( degrees multiplied by 10 * * 7 and rounded to the nearest integer ) . <nl> - / / / Latitudes should be in the range + / - 90 degrees and longitude should be in <nl> - / / / the range + / - 180 degrees ( inclusive ) . <nl> + / / / Points are represented as latitude - longitude pairs in the E7 representation <nl> + / / / ( degrees multiplied by 10 * * 7 and rounded to the nearest integer ) . <nl> + / / / Latitudes should be in the range + / - 90 degrees and longitude should be in <nl> + / / / the range + / - 180 degrees ( inclusive ) . <nl> / / / < / summary > <nl> public sealed partial class Point : pb : : IMessage < Point > { <nl> private static readonly pb : : MessageParser < Point > _parser = new pb : : MessageParser < Point > ( ( ) = > new Point ( ) ) ; <nl> public sealed partial class Point : pb : : IMessage < Point > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / A latitude - longitude rectangle , represented as two diagonally opposite <nl> - / / / points " lo " and " hi " . <nl> + / / / A latitude - longitude rectangle , represented as two diagonally opposite <nl> + / / / points " lo " and " hi " . <nl> / / / < / summary > <nl> public sealed partial class Rectangle : pb : : IMessage < Rectangle > { <nl> private static readonly pb : : MessageParser < Rectangle > _parser = new pb : : MessageParser < Rectangle > ( ( ) = > new Rectangle ( ) ) ; <nl> public sealed partial class Rectangle : pb : : IMessage < Rectangle > { <nl> public const int LoFieldNumber = 1 ; <nl> private global : : Routeguide . Point lo_ ; <nl> / / / < summary > <nl> - / / / One corner of the rectangle . <nl> + / / / One corner of the rectangle . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public global : : Routeguide . Point Lo { <nl> public sealed partial class Rectangle : pb : : IMessage < Rectangle > { <nl> public const int HiFieldNumber = 2 ; <nl> private global : : Routeguide . Point hi_ ; <nl> / / / < summary > <nl> - / / / The other corner of the rectangle . <nl> + / / / The other corner of the rectangle . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public global : : Routeguide . Point Hi { <nl> public sealed partial class Rectangle : pb : : IMessage < Rectangle > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / A feature names something at a given point . <nl> + / / / A feature names something at a given point . <nl> / / / <nl> - / / / If a feature could not be named , the name is empty . <nl> + / / / If a feature could not be named , the name is empty . <nl> / / / < / summary > <nl> public sealed partial class Feature : pb : : IMessage < Feature > { <nl> private static readonly pb : : MessageParser < Feature > _parser = new pb : : MessageParser < Feature > ( ( ) = > new Feature ( ) ) ; <nl> public sealed partial class Feature : pb : : IMessage < Feature > { <nl> public const int NameFieldNumber = 1 ; <nl> private string name_ = " " ; <nl> / / / < summary > <nl> - / / / The name of the feature . <nl> + / / / The name of the feature . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Name { <nl> public sealed partial class Feature : pb : : IMessage < Feature > { <nl> public const int LocationFieldNumber = 2 ; <nl> private global : : Routeguide . Point location_ ; <nl> / / / < summary > <nl> - / / / The point where the feature is detected . <nl> + / / / The point where the feature is detected . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public global : : Routeguide . Point Location { <nl> public sealed partial class Feature : pb : : IMessage < Feature > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / A RouteNote is a message sent while at a given point . <nl> + / / / A RouteNote is a message sent while at a given point . <nl> / / / < / summary > <nl> public sealed partial class RouteNote : pb : : IMessage < RouteNote > { <nl> private static readonly pb : : MessageParser < RouteNote > _parser = new pb : : MessageParser < RouteNote > ( ( ) = > new RouteNote ( ) ) ; <nl> public sealed partial class RouteNote : pb : : IMessage < RouteNote > { <nl> public const int LocationFieldNumber = 1 ; <nl> private global : : Routeguide . Point location_ ; <nl> / / / < summary > <nl> - / / / The location from which the message is sent . <nl> + / / / The location from which the message is sent . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public global : : Routeguide . Point Location { <nl> public sealed partial class RouteNote : pb : : IMessage < RouteNote > { <nl> public const int MessageFieldNumber = 2 ; <nl> private string message_ = " " ; <nl> / / / < summary > <nl> - / / / The message to be sent . <nl> + / / / The message to be sent . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public string Message { <nl> public sealed partial class RouteNote : pb : : IMessage < RouteNote > { <nl> } <nl> <nl> / / / < summary > <nl> - / / / A RouteSummary is received in response to a RecordRoute rpc . <nl> + / / / A RouteSummary is received in response to a RecordRoute rpc . <nl> / / / <nl> - / / / It contains the number of individual points received , the number of <nl> - / / / detected features , and the total distance covered as the cumulative sum of <nl> - / / / the distance between each point . <nl> + / / / It contains the number of individual points received , the number of <nl> + / / / detected features , and the total distance covered as the cumulative sum of <nl> + / / / the distance between each point . <nl> / / / < / summary > <nl> public sealed partial class RouteSummary : pb : : IMessage < RouteSummary > { <nl> private static readonly pb : : MessageParser < RouteSummary > _parser = new pb : : MessageParser < RouteSummary > ( ( ) = > new RouteSummary ( ) ) ; <nl> public sealed partial class RouteSummary : pb : : IMessage < RouteSummary > { <nl> public const int PointCountFieldNumber = 1 ; <nl> private int pointCount_ ; <nl> / / / < summary > <nl> - / / / The number of points received . <nl> + / / / The number of points received . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int PointCount { <nl> public sealed partial class RouteSummary : pb : : IMessage < RouteSummary > { <nl> public const int FeatureCountFieldNumber = 2 ; <nl> private int featureCount_ ; <nl> / / / < summary > <nl> - / / / The number of known features passed while traversing the route . <nl> + / / / The number of known features passed while traversing the route . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int FeatureCount { <nl> public sealed partial class RouteSummary : pb : : IMessage < RouteSummary > { <nl> public const int DistanceFieldNumber = 3 ; <nl> private int distance_ ; <nl> / / / < summary > <nl> - / / / The distance covered in metres . <nl> + / / / The distance covered in metres . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int Distance { <nl> public sealed partial class RouteSummary : pb : : IMessage < RouteSummary > { <nl> public const int ElapsedTimeFieldNumber = 4 ; <nl> private int elapsedTime_ ; <nl> / / / < summary > <nl> - / / / The duration of the traversal in seconds . <nl> + / / / The duration of the traversal in seconds . <nl> / / / < / summary > <nl> [ global : : System . Diagnostics . DebuggerNonUserCodeAttribute ] <nl> public int ElapsedTime { <nl> mmm a / examples / csharp / route_guide / RouteGuide / RouteGuide . csproj <nl> ppp b / examples / csharp / route_guide / RouteGuide / RouteGuide . csproj <nl> <nl> < AssemblyName > RouteGuide < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> < FileAlignment > 512 < / FileAlignment > <nl> - < NuGetPackageImportStamp > de2137f9 < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < DebugSymbols > true < / DebugSymbols > <nl> <nl> < WarningLevel > 4 < / WarningLevel > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " Newtonsoft . Json , Version = 7 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = 30ad4fe6b2a6aeed , processorArchitecture = MSIL " > <nl> < SpecificVersion > False < / SpecificVersion > <nl> <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> < Reference Include = " System . Core " / > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> + < / Reference > <nl> < Reference Include = " System . Xml . Linq " / > <nl> < Reference Include = " System . Data . DataSetExtensions " / > <nl> < Reference Include = " Microsoft . CSharp " / > <nl> < Reference Include = " System . Data " / > <nl> < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> <nl> < / None > <nl> < / ItemGroup > <nl> < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> Other similar extension points exist , see Microsoft . Common . targets . <nl> <nl> < Target Name = " AfterBuild " > <nl> < / Target > <nl> - - > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / RouteGuide / RouteGuideGrpc . cs <nl> ppp b / examples / csharp / route_guide / RouteGuide / RouteGuideGrpc . cs <nl> <nl> using System ; <nl> using System . Threading ; <nl> using System . Threading . Tasks ; <nl> - using Grpc . Core ; <nl> + using grpc = global : : Grpc . Core ; <nl> <nl> namespace Routeguide { <nl> / / / < summary > <nl> - / / / Interface exported by the server . <nl> + / / / Interface exported by the server . <nl> / / / < / summary > <nl> - public static class RouteGuide <nl> + public static partial class RouteGuide <nl> { <nl> static readonly string __ServiceName = " routeguide . RouteGuide " ; <nl> <nl> - static readonly Marshaller < global : : Routeguide . Point > __Marshaller_Point = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Point . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Routeguide . Feature > __Marshaller_Feature = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Feature . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Routeguide . Rectangle > __Marshaller_Rectangle = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Rectangle . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Routeguide . RouteSummary > __Marshaller_RouteSummary = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . RouteSummary . Parser . ParseFrom ) ; <nl> - static readonly Marshaller < global : : Routeguide . RouteNote > __Marshaller_RouteNote = Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . RouteNote . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Routeguide . Point > __Marshaller_Point = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Point . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Routeguide . Feature > __Marshaller_Feature = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Feature . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Routeguide . Rectangle > __Marshaller_Rectangle = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . Rectangle . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Routeguide . RouteSummary > __Marshaller_RouteSummary = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . RouteSummary . Parser . ParseFrom ) ; <nl> + static readonly grpc : : Marshaller < global : : Routeguide . RouteNote > __Marshaller_RouteNote = grpc : : Marshallers . Create ( ( arg ) = > global : : Google . Protobuf . MessageExtensions . ToByteArray ( arg ) , global : : Routeguide . RouteNote . Parser . ParseFrom ) ; <nl> <nl> - static readonly Method < global : : Routeguide . Point , global : : Routeguide . Feature > __Method_GetFeature = new Method < global : : Routeguide . Point , global : : Routeguide . Feature > ( <nl> - MethodType . Unary , <nl> + static readonly grpc : : Method < global : : Routeguide . Point , global : : Routeguide . Feature > __Method_GetFeature = new grpc : : Method < global : : Routeguide . Point , global : : Routeguide . Feature > ( <nl> + grpc : : MethodType . Unary , <nl> __ServiceName , <nl> " GetFeature " , <nl> __Marshaller_Point , <nl> __Marshaller_Feature ) ; <nl> <nl> - static readonly Method < global : : Routeguide . Rectangle , global : : Routeguide . Feature > __Method_ListFeatures = new Method < global : : Routeguide . Rectangle , global : : Routeguide . Feature > ( <nl> - MethodType . ServerStreaming , <nl> + static readonly grpc : : Method < global : : Routeguide . Rectangle , global : : Routeguide . Feature > __Method_ListFeatures = new grpc : : Method < global : : Routeguide . Rectangle , global : : Routeguide . Feature > ( <nl> + grpc : : MethodType . ServerStreaming , <nl> __ServiceName , <nl> " ListFeatures " , <nl> __Marshaller_Rectangle , <nl> __Marshaller_Feature ) ; <nl> <nl> - static readonly Method < global : : Routeguide . Point , global : : Routeguide . RouteSummary > __Method_RecordRoute = new Method < global : : Routeguide . Point , global : : Routeguide . RouteSummary > ( <nl> - MethodType . ClientStreaming , <nl> + static readonly grpc : : Method < global : : Routeguide . Point , global : : Routeguide . RouteSummary > __Method_RecordRoute = new grpc : : Method < global : : Routeguide . Point , global : : Routeguide . RouteSummary > ( <nl> + grpc : : MethodType . ClientStreaming , <nl> __ServiceName , <nl> " RecordRoute " , <nl> __Marshaller_Point , <nl> __Marshaller_RouteSummary ) ; <nl> <nl> - static readonly Method < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > __Method_RouteChat = new Method < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > ( <nl> - MethodType . DuplexStreaming , <nl> + static readonly grpc : : Method < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > __Method_RouteChat = new grpc : : Method < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > ( <nl> + grpc : : MethodType . DuplexStreaming , <nl> __ServiceName , <nl> " RouteChat " , <nl> __Marshaller_RouteNote , <nl> public static class RouteGuide <nl> } <nl> <nl> / / / < summary > Base class for server - side implementations of RouteGuide < / summary > <nl> - public abstract class RouteGuideBase <nl> + public abstract partial class RouteGuideBase <nl> { <nl> / / / < summary > <nl> - / / / A simple RPC . <nl> + / / / A simple RPC . <nl> / / / <nl> - / / / Obtains the feature at a given position . <nl> + / / / Obtains the feature at a given position . <nl> / / / <nl> - / / / A feature with an empty name is returned if there ' s no feature at the given <nl> - / / / position . <nl> + / / / A feature with an empty name is returned if there ' s no feature at the given <nl> + / / / position . <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task < global : : Routeguide . Feature > GetFeature ( global : : Routeguide . Point request , ServerCallContext context ) <nl> + / / / < param name = " request " > The request received from the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > The response to send back to the client ( wrapped by a task ) . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task < global : : Routeguide . Feature > GetFeature ( global : : Routeguide . Point request , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> / / / < summary > <nl> - / / / A server - to - client streaming RPC . <nl> + / / / A server - to - client streaming RPC . <nl> / / / <nl> - / / / Obtains the Features available within the given Rectangle . Results are <nl> - / / / streamed rather than returned at once ( e . g . in a response message with a <nl> - / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> - / / / huge number of features . <nl> + / / / Obtains the Features available within the given Rectangle . Results are <nl> + / / / streamed rather than returned at once ( e . g . in a response message with a <nl> + / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> + / / / huge number of features . <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task ListFeatures ( global : : Routeguide . Rectangle request , IServerStreamWriter < global : : Routeguide . Feature > responseStream , ServerCallContext context ) <nl> + / / / < param name = " request " > The request received from the client . < / param > <nl> + / / / < param name = " responseStream " > Used for sending responses back to the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > A task indicating completion of the handler . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task ListFeatures ( global : : Routeguide . Rectangle request , grpc : : IServerStreamWriter < global : : Routeguide . Feature > responseStream , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> / / / < summary > <nl> - / / / A client - to - server streaming RPC . <nl> + / / / A client - to - server streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of Points on a route being traversed , returning a <nl> - / / / RouteSummary when traversal is completed . <nl> + / / / Accepts a stream of Points on a route being traversed , returning a <nl> + / / / RouteSummary when traversal is completed . <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task < global : : Routeguide . RouteSummary > RecordRoute ( IAsyncStreamReader < global : : Routeguide . Point > requestStream , ServerCallContext context ) <nl> + / / / < param name = " requestStream " > Used for reading requests from the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > The response to send back to the client ( wrapped by a task ) . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task < global : : Routeguide . RouteSummary > RecordRoute ( grpc : : IAsyncStreamReader < global : : Routeguide . Point > requestStream , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> / / / < summary > <nl> - / / / A Bidirectional streaming RPC . <nl> + / / / A Bidirectional streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> - / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> + / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> + / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> / / / < / summary > <nl> - public virtual global : : System . Threading . Tasks . Task RouteChat ( IAsyncStreamReader < global : : Routeguide . RouteNote > requestStream , IServerStreamWriter < global : : Routeguide . RouteNote > responseStream , ServerCallContext context ) <nl> + / / / < param name = " requestStream " > Used for reading requests from the client . < / param > <nl> + / / / < param name = " responseStream " > Used for sending responses back to the client . < / param > <nl> + / / / < param name = " context " > The context of the server - side call handler being invoked . < / param > <nl> + / / / < returns > A task indicating completion of the handler . < / returns > <nl> + public virtual global : : System . Threading . Tasks . Task RouteChat ( grpc : : IAsyncStreamReader < global : : Routeguide . RouteNote > requestStream , grpc : : IServerStreamWriter < global : : Routeguide . RouteNote > responseStream , grpc : : ServerCallContext context ) <nl> { <nl> - throw new RpcException ( new Status ( StatusCode . Unimplemented , " " ) ) ; <nl> + throw new grpc : : RpcException ( new grpc : : Status ( grpc : : StatusCode . Unimplemented , " " ) ) ; <nl> } <nl> <nl> } <nl> <nl> / / / < summary > Client for RouteGuide < / summary > <nl> - public class RouteGuideClient : ClientBase < RouteGuideClient > <nl> + public partial class RouteGuideClient : grpc : : ClientBase < RouteGuideClient > <nl> { <nl> / / / < summary > Creates a new client for RouteGuide < / summary > <nl> / / / < param name = " channel " > The channel to use to make remote calls . < / param > <nl> - public RouteGuideClient ( Channel channel ) : base ( channel ) <nl> + public RouteGuideClient ( grpc : : Channel channel ) : base ( channel ) <nl> { <nl> } <nl> / / / < summary > Creates a new client for RouteGuide that uses a custom < c > CallInvoker < / c > . < / summary > <nl> / / / < param name = " callInvoker " > The callInvoker to use to make remote calls . < / param > <nl> - public RouteGuideClient ( CallInvoker callInvoker ) : base ( callInvoker ) <nl> + public RouteGuideClient ( grpc : : CallInvoker callInvoker ) : base ( callInvoker ) <nl> { <nl> } <nl> / / / < summary > Protected parameterless constructor to allow creation of test doubles . < / summary > <nl> protected RouteGuideClient ( ClientBaseConfiguration configuration ) : base ( configu <nl> } <nl> <nl> / / / < summary > <nl> - / / / A simple RPC . <nl> + / / / A simple RPC . <nl> / / / <nl> - / / / Obtains the feature at a given position . <nl> + / / / Obtains the feature at a given position . <nl> / / / <nl> - / / / A feature with an empty name is returned if there ' s no feature at the given <nl> - / / / position . <nl> + / / / A feature with an empty name is returned if there ' s no feature at the given <nl> + / / / position . <nl> / / / < / summary > <nl> - public virtual global : : Routeguide . Feature GetFeature ( global : : Routeguide . Point request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Routeguide . Feature GetFeature ( global : : Routeguide . Point request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return GetFeature ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return GetFeature ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / A simple RPC . <nl> + / / / A simple RPC . <nl> / / / <nl> - / / / Obtains the feature at a given position . <nl> + / / / Obtains the feature at a given position . <nl> / / / <nl> - / / / A feature with an empty name is returned if there ' s no feature at the given <nl> - / / / position . <nl> + / / / A feature with an empty name is returned if there ' s no feature at the given <nl> + / / / position . <nl> / / / < / summary > <nl> - public virtual global : : Routeguide . Feature GetFeature ( global : : Routeguide . Point request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The response received from the server . < / returns > <nl> + public virtual global : : Routeguide . Feature GetFeature ( global : : Routeguide . Point request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . BlockingUnaryCall ( __Method_GetFeature , null , options , request ) ; <nl> } <nl> / / / < summary > <nl> - / / / A simple RPC . <nl> + / / / A simple RPC . <nl> / / / <nl> - / / / Obtains the feature at a given position . <nl> + / / / Obtains the feature at a given position . <nl> / / / <nl> - / / / A feature with an empty name is returned if there ' s no feature at the given <nl> - / / / position . <nl> + / / / A feature with an empty name is returned if there ' s no feature at the given <nl> + / / / position . <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Routeguide . Feature > GetFeatureAsync ( global : : Routeguide . Point request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Routeguide . Feature > GetFeatureAsync ( global : : Routeguide . Point request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return GetFeatureAsync ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return GetFeatureAsync ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / A simple RPC . <nl> + / / / A simple RPC . <nl> / / / <nl> - / / / Obtains the feature at a given position . <nl> + / / / Obtains the feature at a given position . <nl> / / / <nl> - / / / A feature with an empty name is returned if there ' s no feature at the given <nl> - / / / position . <nl> + / / / A feature with an empty name is returned if there ' s no feature at the given <nl> + / / / position . <nl> / / / < / summary > <nl> - public virtual AsyncUnaryCall < global : : Routeguide . Feature > GetFeatureAsync ( global : : Routeguide . Point request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncUnaryCall < global : : Routeguide . Feature > GetFeatureAsync ( global : : Routeguide . Point request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncUnaryCall ( __Method_GetFeature , null , options , request ) ; <nl> } <nl> / / / < summary > <nl> - / / / A server - to - client streaming RPC . <nl> + / / / A server - to - client streaming RPC . <nl> / / / <nl> - / / / Obtains the Features available within the given Rectangle . Results are <nl> - / / / streamed rather than returned at once ( e . g . in a response message with a <nl> - / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> - / / / huge number of features . <nl> + / / / Obtains the Features available within the given Rectangle . Results are <nl> + / / / streamed rather than returned at once ( e . g . in a response message with a <nl> + / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> + / / / huge number of features . <nl> / / / < / summary > <nl> - public virtual AsyncServerStreamingCall < global : : Routeguide . Feature > ListFeatures ( global : : Routeguide . Rectangle request , Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncServerStreamingCall < global : : Routeguide . Feature > ListFeatures ( global : : Routeguide . Rectangle request , grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return ListFeatures ( request , new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return ListFeatures ( request , new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / A server - to - client streaming RPC . <nl> + / / / A server - to - client streaming RPC . <nl> / / / <nl> - / / / Obtains the Features available within the given Rectangle . Results are <nl> - / / / streamed rather than returned at once ( e . g . in a response message with a <nl> - / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> - / / / huge number of features . <nl> + / / / Obtains the Features available within the given Rectangle . Results are <nl> + / / / streamed rather than returned at once ( e . g . in a response message with a <nl> + / / / repeated field ) , as the rectangle may cover a large area and contain a <nl> + / / / huge number of features . <nl> / / / < / summary > <nl> - public virtual AsyncServerStreamingCall < global : : Routeguide . Feature > ListFeatures ( global : : Routeguide . Rectangle request , CallOptions options ) <nl> + / / / < param name = " request " > The request to send to the server . < / param > <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncServerStreamingCall < global : : Routeguide . Feature > ListFeatures ( global : : Routeguide . Rectangle request , grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncServerStreamingCall ( __Method_ListFeatures , null , options , request ) ; <nl> } <nl> / / / < summary > <nl> - / / / A client - to - server streaming RPC . <nl> + / / / A client - to - server streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of Points on a route being traversed , returning a <nl> - / / / RouteSummary when traversal is completed . <nl> + / / / Accepts a stream of Points on a route being traversed , returning a <nl> + / / / RouteSummary when traversal is completed . <nl> / / / < / summary > <nl> - public virtual AsyncClientStreamingCall < global : : Routeguide . Point , global : : Routeguide . RouteSummary > RecordRoute ( Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncClientStreamingCall < global : : Routeguide . Point , global : : Routeguide . RouteSummary > RecordRoute ( grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return RecordRoute ( new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return RecordRoute ( new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / A client - to - server streaming RPC . <nl> + / / / A client - to - server streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of Points on a route being traversed , returning a <nl> - / / / RouteSummary when traversal is completed . <nl> + / / / Accepts a stream of Points on a route being traversed , returning a <nl> + / / / RouteSummary when traversal is completed . <nl> / / / < / summary > <nl> - public virtual AsyncClientStreamingCall < global : : Routeguide . Point , global : : Routeguide . RouteSummary > RecordRoute ( CallOptions options ) <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncClientStreamingCall < global : : Routeguide . Point , global : : Routeguide . RouteSummary > RecordRoute ( grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncClientStreamingCall ( __Method_RecordRoute , null , options ) ; <nl> } <nl> / / / < summary > <nl> - / / / A Bidirectional streaming RPC . <nl> + / / / A Bidirectional streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> - / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> + / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> + / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> / / / < / summary > <nl> - public virtual AsyncDuplexStreamingCall < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > RouteChat ( Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> + / / / < param name = " headers " > The initial metadata to send with the call . This parameter is optional . < / param > <nl> + / / / < param name = " deadline " > An optional deadline for the call . The call will be cancelled if deadline is hit . < / param > <nl> + / / / < param name = " cancellationToken " > An optional token for canceling the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncDuplexStreamingCall < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > RouteChat ( grpc : : Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> { <nl> - return RouteChat ( new CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> + return RouteChat ( new grpc : : CallOptions ( headers , deadline , cancellationToken ) ) ; <nl> } <nl> / / / < summary > <nl> - / / / A Bidirectional streaming RPC . <nl> + / / / A Bidirectional streaming RPC . <nl> / / / <nl> - / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> - / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> + / / / Accepts a stream of RouteNotes sent while a route is being traversed , <nl> + / / / while receiving other RouteNotes ( e . g . from other users ) . <nl> / / / < / summary > <nl> - public virtual AsyncDuplexStreamingCall < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > RouteChat ( CallOptions options ) <nl> + / / / < param name = " options " > The options for the call . < / param > <nl> + / / / < returns > The call object . < / returns > <nl> + public virtual grpc : : AsyncDuplexStreamingCall < global : : Routeguide . RouteNote , global : : Routeguide . RouteNote > RouteChat ( grpc : : CallOptions options ) <nl> { <nl> return CallInvoker . AsyncDuplexStreamingCall ( __Method_RouteChat , null , options ) ; <nl> } <nl> + / / / < summary > Creates a new instance of client from given < c > ClientBaseConfiguration < / c > . < / summary > <nl> protected override RouteGuideClient NewInstance ( ClientBaseConfiguration configuration ) <nl> { <nl> return new RouteGuideClient ( configuration ) ; <nl> protected override RouteGuideClient NewInstance ( ClientBaseConfiguration configur <nl> } <nl> <nl> / / / < summary > Creates service definition that can be registered with a server < / summary > <nl> - public static ServerServiceDefinition BindService ( RouteGuideBase serviceImpl ) <nl> + / / / < param name = " serviceImpl " > An object implementing the server - side handling logic . < / param > <nl> + public static grpc : : ServerServiceDefinition BindService ( RouteGuideBase serviceImpl ) <nl> { <nl> - return ServerServiceDefinition . CreateBuilder ( ) <nl> + return grpc : : ServerServiceDefinition . CreateBuilder ( ) <nl> . AddMethod ( __Method_GetFeature , serviceImpl . GetFeature ) <nl> . AddMethod ( __Method_ListFeatures , serviceImpl . ListFeatures ) <nl> . AddMethod ( __Method_RecordRoute , serviceImpl . RecordRoute ) <nl> mmm a / examples / csharp / route_guide / RouteGuide / packages . config <nl> ppp b / examples / csharp / route_guide / RouteGuide / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> < package id = " Newtonsoft . Json " version = " 7 . 0 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / RouteGuideClient / RouteGuideClient . csproj <nl> ppp b / examples / csharp / route_guide / RouteGuideClient / RouteGuideClient . csproj <nl> <nl> < AssemblyName > RouteGuideClient < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> < FileAlignment > 512 < / FileAlignment > <nl> - < NuGetPackageImportStamp > b880049a < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < PlatformTarget > AnyCPU < / PlatformTarget > <nl> <nl> < WarningLevel > 4 < / WarningLevel > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " Newtonsoft . Json , Version = 7 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = 30ad4fe6b2a6aeed , processorArchitecture = MSIL " > <nl> < SpecificVersion > False < / SpecificVersion > <nl> <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " System . Xml . Linq " / > <nl> < Reference Include = " System . Data . DataSetExtensions " / > <nl> <nl> < / ProjectReference > <nl> < / ItemGroup > <nl> < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> Other similar extension points exist , see Microsoft . Common . targets . <nl> <nl> < Target Name = " AfterBuild " > <nl> < / Target > <nl> - - > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / RouteGuideClient / packages . config <nl> ppp b / examples / csharp / route_guide / RouteGuideClient / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> < package id = " Newtonsoft . Json " version = " 7 . 0 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / RouteGuideServer / RouteGuideServer . csproj <nl> ppp b / examples / csharp / route_guide / RouteGuideServer / RouteGuideServer . csproj <nl> <nl> < AssemblyName > RouteGuideServer < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> < FileAlignment > 512 < / FileAlignment > <nl> - < NuGetPackageImportStamp > 946ecc79 < / NuGetPackageImportStamp > <nl> + < NuGetPackageImportStamp > <nl> + < / NuGetPackageImportStamp > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> < PlatformTarget > AnyCPU < / PlatformTarget > <nl> <nl> < WarningLevel > 4 < / WarningLevel > <nl> < / PropertyGroup > <nl> < ItemGroup > <nl> - < Reference Include = " Google . Protobuf , Version = 3 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 0 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Reference Include = " Google . Protobuf , Version = 3 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = a7d26565bac4d604 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> - < Reference Include = " Grpc . Core , Version = 1 . 0 . 1 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ Grpc . Core . 1 . 0 . 1 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Reference Include = " Grpc . Core , Version = 1 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = d754f35622e28bad , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ Grpc . Core . 1 . 2 . 2 \ lib \ net45 \ Grpc . Core . dll < / HintPath > <nl> + < Private > True < / Private > <nl> < / Reference > <nl> < Reference Include = " Newtonsoft . Json , Version = 7 . 0 . 0 . 0 , Culture = neutral , PublicKeyToken = 30ad4fe6b2a6aeed , processorArchitecture = MSIL " > <nl> < SpecificVersion > False < / SpecificVersion > <nl> <nl> < / Reference > <nl> < Reference Include = " System " / > <nl> < Reference Include = " System . Core " / > <nl> + < Reference Include = " System . Interactive . Async , Version = 3 . 0 . 1000 . 0 , Culture = neutral , PublicKeyToken = 94bc3704cddfc263 , processorArchitecture = MSIL " > <nl> + < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> + < Private > True < / Private > <nl> + < / Reference > <nl> < Reference Include = " System . Xml . Linq " / > <nl> < Reference Include = " System . Data . DataSetExtensions " / > <nl> < Reference Include = " Microsoft . CSharp " / > <nl> < Reference Include = " System . Data " / > <nl> < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async , Version = 1 . 2 . 0 . 0 , Culture = neutral , PublicKeyToken = 31bf3856ad364e35 , processorArchitecture = MSIL " > <nl> - < SpecificVersion > False < / SpecificVersion > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 0 . 0 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Compile Include = " Program . cs " / > <nl> <nl> < / ProjectReference > <nl> < / ItemGroup > <nl> < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < Import Project = " . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> + < Import Project = " . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets " Condition = " Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " / > <nl> < Target Name = " EnsureNuGetPackageBuildImports " BeforeTargets = " PrepareForBuild " > <nl> < PropertyGroup > <nl> - < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Enable NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> + < ErrorText > This project references NuGet package ( s ) that are missing on this computer . Use NuGet Package Restore to download them . For more information , see http : / / go . microsoft . com / fwlink / ? LinkID = 322105 . The missing file is { 0 } . < / ErrorText > <nl> < / PropertyGroup > <nl> - < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 0 . 1 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> + < Error Condition = " ! Exists ( ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) " Text = " $ ( [ System . String ] : : Format ( ' $ ( ErrorText ) ' , ' . . \ packages \ Grpc . Core . 1 . 2 . 2 \ build \ net45 \ Grpc . Core . targets ' ) ) " / > <nl> < / Target > <nl> < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> Other similar extension points exist , see Microsoft . Common . targets . <nl> <nl> < Target Name = " AfterBuild " > <nl> < / Target > <nl> - - > <nl> - < / Project > <nl> + < / Project > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / RouteGuideServer / packages . config <nl> ppp b / examples / csharp / route_guide / RouteGuideServer / packages . config <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Grpc " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Core " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 0 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> + < package id = " Grpc " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Core " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> + < package id = " Grpc . Tools " version = " 1 . 2 . 2 " targetFramework = " net45 " / > <nl> < package id = " Newtonsoft . Json " version = " 7 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Grpc . Tools " version = " 1 . 0 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> + < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> + < / packages > <nl> \ No newline at end of file <nl> mmm a / examples / csharp / route_guide / generate_protos . bat <nl> ppp b / examples / csharp / route_guide / generate_protos . bat <nl> setlocal <nl> @ rem enter this directory <nl> cd / d % ~ dp0 <nl> <nl> - set TOOLS_PATH = packages \ Grpc . Tools . 1 . 0 . 0 \ tools \ windows_x86 <nl> + set TOOLS_PATH = packages \ Grpc . Tools . 1 . 2 . 2 \ tools \ windows_x86 <nl> <nl> % TOOLS_PATH % \ protoc . exe - I . . / . . / protos - - csharp_out RouteGuide . . / . . / protos / route_guide . proto - - grpc_out RouteGuide - - plugin = protoc - gen - grpc = % TOOLS_PATH % \ grpc_csharp_plugin . exe <nl> <nl> | Merge pull request from jtattermusch / upgrade_examples | grpc/grpc | 7ef27a88b3dd3d9fa3c927722588793f82b82c96 | 2017-04-21T07:05:00Z |
mmm a / src / net . cpp <nl> ppp b / src / net . cpp <nl> const uint256 & CNetMessage : : GetMessageHash ( ) const <nl> <nl> <nl> / / requires LOCK ( cs_vSend ) <nl> - size_t SocketSendData ( CNode * pnode ) <nl> + size_t CConnman : : SocketSendData ( CNode * pnode ) <nl> { <nl> auto it = pnode - > vSendMsg . begin ( ) ; <nl> size_t nSentSize = 0 ; <nl> size_t SocketSendData ( CNode * pnode ) <nl> if ( pnode - > nSendOffset = = data . size ( ) ) { <nl> pnode - > nSendOffset = 0 ; <nl> pnode - > nSendSize - = data . size ( ) ; <nl> + pnode - > fPauseSend = pnode - > nSendSize > nSendBufferMaxSize ; <nl> it + + ; <nl> } else { <nl> / / could not send full message ; stop sending more <nl> void CConnman : : ThreadSocketHandler ( ) <nl> TRY_LOCK ( pnode - > cs_vSend , lockSend ) ; <nl> if ( lockSend ) { <nl> size_t nBytes = SocketSendData ( pnode ) ; <nl> - if ( nBytes ) <nl> + if ( nBytes ) { <nl> RecordBytesSent ( nBytes ) ; <nl> + } <nl> } <nl> } <nl> <nl> void CConnman : : ThreadMessageHandler ( ) <nl> if ( lockRecv ) <nl> { <nl> bool fMoreNodeWork = GetNodeSignals ( ) . ProcessMessages ( pnode , * this , flagInterruptMsgProc ) ; <nl> - fMoreWork | = ( fMoreNodeWork & & pnode - > nSendSize < GetSendBufferSize ( ) ) ; <nl> + fMoreWork | = ( fMoreNodeWork & & ! pnode - > fPauseSend ) ; <nl> } <nl> } <nl> if ( flagInterruptMsgProc ) <nl> CNode : : CNode ( NodeId idIn , ServiceFlags nLocalServicesIn , int nMyStartingHeightIn <nl> lastSentFeeFilter = 0 ; <nl> nextSendTimeFeeFilter = 0 ; <nl> fPauseRecv = false ; <nl> + fPauseSend = false ; <nl> nProcessQueueSize = 0 ; <nl> <nl> BOOST_FOREACH ( const std : : string & msg , getAllNetMessageTypes ( ) ) <nl> void CConnman : : PushMessage ( CNode * pnode , CSerializedNetMsg & & msg ) <nl> pnode - > mapSendBytesPerMsgCmd [ msg . command ] + = nTotalSize ; <nl> pnode - > nSendSize + = nTotalSize ; <nl> <nl> + if ( pnode - > nSendSize > nSendBufferMaxSize ) <nl> + pnode - > fPauseSend = true ; <nl> pnode - > vSendMsg . push_back ( std : : move ( serializedHeader ) ) ; <nl> if ( nMessageSize ) <nl> pnode - > vSendMsg . push_back ( std : : move ( msg . data ) ) ; <nl> mmm a / src / net . h <nl> ppp b / src / net . h <nl> class CConnman <nl> <nl> NodeId GetNewNodeId ( ) ; <nl> <nl> + size_t SocketSendData ( CNode * pnode ) ; <nl> / / ! check is the banlist has unwritten changes <nl> bool BannedSetIsDirty ( ) ; <nl> / / ! set the " dirty " flag for the banlist <nl> void Discover ( boost : : thread_group & threadGroup ) ; <nl> void MapPort ( bool fUseUPnP ) ; <nl> unsigned short GetListenPort ( ) ; <nl> bool BindListenPort ( const CService & bindAddr , std : : string & strError , bool fWhitelisted = false ) ; <nl> - size_t SocketSendData ( CNode * pnode ) ; <nl> <nl> struct CombinerAll <nl> { <nl> class CNode <nl> <nl> const uint64_t nKeyedNetGroup ; <nl> std : : atomic_bool fPauseRecv ; <nl> + std : : atomic_bool fPauseSend ; <nl> protected : <nl> <nl> mapMsgCmdSize mapSendBytesPerMsgCmd ; <nl> mmm a / src / net_processing . cpp <nl> ppp b / src / net_processing . cpp <nl> static void RelayAddress ( const CAddress & addr , bool fReachable , CConnman & connma <nl> void static ProcessGetData ( CNode * pfrom , const Consensus : : Params & consensusParams , CConnman & connman , std : : atomic < bool > & interruptMsgProc ) <nl> { <nl> std : : deque < CInv > : : iterator it = pfrom - > vRecvGetData . begin ( ) ; <nl> - unsigned int nMaxSendBufferSize = connman . GetSendBufferSize ( ) ; <nl> vector < CInv > vNotFound ; <nl> CNetMsgMaker msgMaker ( pfrom - > GetSendVersion ( ) ) ; <nl> LOCK ( cs_main ) ; <nl> <nl> while ( it ! = pfrom - > vRecvGetData . end ( ) ) { <nl> / / Don ' t bother if send buffer is too full to respond anyway <nl> - if ( pfrom - > nSendSize > = nMaxSendBufferSize ) <nl> + if ( pfrom - > fPauseSend ) <nl> break ; <nl> <nl> const CInv & inv = * it ; <nl> bool static ProcessMessage ( CNode * pfrom , string strCommand , CDataStream & vRecv , <nl> bool ProcessMessages ( CNode * pfrom , CConnman & connman , std : : atomic < bool > & interruptMsgProc ) <nl> { <nl> const CChainParams & chainparams = Params ( ) ; <nl> - unsigned int nMaxSendBufferSize = connman . GetSendBufferSize ( ) ; <nl> / / <nl> / / Message format <nl> / / ( 4 ) message start <nl> bool ProcessMessages ( CNode * pfrom , CConnman & connman , std : : atomic < bool > & interru <nl> if ( ! pfrom - > vRecvGetData . empty ( ) ) return true ; <nl> <nl> / / Don ' t bother if send buffer is too full to respond anyway <nl> - if ( pfrom - > nSendSize > = nMaxSendBufferSize ) <nl> + if ( pfrom - > fPauseSend ) <nl> return false ; <nl> <nl> std : : list < CNetMessage > msgs ; <nl> | net : add a flag to indicate when a node ' s send buffer is full | bitcoin/bitcoin | 991955ee81034dc3fbc1c2a8e60c04fc9e0b538c | 2017-01-13T04:05:59Z |
new file mode 100644 <nl> index 000000000 . . b93e4a13d <nl> mmm / dev / null <nl> ppp b / . github / workflows / fuzzers . yml <nl> <nl> + name : Run fuzzers on stored corpus and test it with valgrind <nl> + <nl> + # In the case of a pull request happening at the same time as a cron <nl> + # job , there is a risk two jobs run at the same time . Therefore , <nl> + # the corpus is only uploaded for the master branch . Pull requests will <nl> + # fuzz for a short while , but the results are not uploaded . <nl> + on : <nl> + push : <nl> + pull_request : <nl> + schedule : <nl> + - cron : 23 * / 8 * * * <nl> + <nl> + jobs : <nl> + build : <nl> + runs - on : ubuntu - latest <nl> + env : <nl> + allfuzzers : parser dump <nl> + steps : <nl> + - name : Install packages necessary for building <nl> + run : | <nl> + sudo apt - get install - - quiet ninja - build valgrind <nl> + wget https : / / apt . llvm . org / llvm . sh <nl> + chmod + x llvm . sh <nl> + sudo . / llvm . sh 8 <nl> + <nl> + - uses : actions / checkout @ v1 <nl> + # with : <nl> + # remove this once integrated <nl> + # ref : paul / fuzz_experiment <nl> + - name : Download the corpus from the last run <nl> + run : | <nl> + wget - - quiet https : / / dl . bintray . com / pauldreik / simdjson - fuzz - corpus / corpus / corpus . tar <nl> + tar xf corpus . tar <nl> + rm corpus . tar <nl> + - name : List clang versions <nl> + run : | <nl> + ls / usr / bin / clang * <nl> + which clang + + <nl> + clang + + - - version <nl> + - name : Build all the variants <nl> + run : fuzz / build_fuzzer_variants . sh <nl> + - name : Run the fastest fuzzer to explore fast <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + mkdir - p out / $ fuzzer # in case this is a new fuzzer , or corpus . tar is broken <nl> + build - ossfuzz - fast8 / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 30 <nl> + done <nl> + - name : Run the other fuzzer variants for $ fuzzer , with sanitizers etc <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + build - ossfuzz - withavx / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 20 <nl> + build - ossfuzz - noavx / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 10 <nl> + build - ossfuzz - noavx8 / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 10 <nl> + echo disable msan runs , it fails inside the fuzzing engine and not the fuzzed code ! <nl> + echo build - ossfuzz - msan - noavx8 / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 10 - reload = 0 <nl> + echo build - ossfuzz - msan - withavx8 / fuzz / fuzz_ $ fuzzer out / $ fuzzer - max_total_time = 10 - reload = 0 <nl> + echo now have $ ( ls out / $ fuzzer | wc - l ) files in corpus <nl> + done <nl> + - name : Minimize the corpus with the fast fuzzer <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + mkdir - p out / cmin / $ fuzzer <nl> + build - ossfuzz - fast8 / fuzz / fuzz_ $ fuzzer - merge = 1 out / cmin / $ fuzzer out / $ fuzzer <nl> + rm - rf out / $ fuzzer <nl> + mv out / cmin / $ fuzzer out / $ fuzzer <nl> + done <nl> + - name : Package the corpus into an artifact <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + tar rf corpus . tar out / $ fuzzer <nl> + done <nl> + - name : Save the corpus as a github artifact <nl> + uses : actions / upload - artifact @ v1 <nl> + with : <nl> + name : corpus <nl> + path : corpus . tar <nl> + - name : Run the corpus through valgrind ( normal build ) <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + find out / $ fuzzer - type f | sort | xargs valgrind build - plain - noavx / fuzz / fuzz_ $ fuzzer 2 > & 1 | tee valgrind - $ fuzzer - noavx . txt <nl> + done <nl> + - name : Run the corpus through valgrind ( noavx build ) <nl> + run : | <nl> + for fuzzer in $ allfuzzers ; do <nl> + find out / $ fuzzer - type f | sort | xargs valgrind build - plain - normal / fuzz / fuzz_ $ fuzzer 2 > & 1 | tee valgrind - $ fuzzer - normal . txt <nl> + done <nl> + - name : Compress the valgrind output <nl> + run : tar cf valgrind . tar valgrind - * . txt <nl> + - name : Save valgrind output as a github artifact <nl> + uses : actions / upload - artifact @ v1 <nl> + with : <nl> + name : valgrindresults <nl> + path : valgrind . tar <nl> + - name : Upload the corpus and results to bintray if we are on master <nl> + run : | <nl> + if [ $ ( git rev - parse - - verify HEAD ) = $ ( git rev - parse - - verify origin / master ) ] ; then <nl> + echo uploading each artifact twice , otherwise it will not be published <nl> + curl - T corpus . tar - upauldreik : $ { { secrets . bintrayApiKey } } https : / / api . bintray . com / content / pauldreik / simdjson - fuzz - corpus / corpus / 0 / corpus / corpus . tar " ; publish = 1 ; override = 1 " <nl> + curl - T corpus . tar - upauldreik : $ { { secrets . bintrayApiKey } } https : / / api . bintray . com / content / pauldreik / simdjson - fuzz - corpus / corpus / 0 / corpus / corpus . tar " ; publish = 1 ; override = 1 " <nl> + curl - T valgrind . tar - upauldreik : $ { { secrets . bintrayApiKey } } https : / / api . bintray . com / content / pauldreik / simdjson - fuzz - corpus / corpus / 0 / corpus / valgrind . tar " ; publish = 1 ; override = 1 " <nl> + curl - T valgrind . tar - upauldreik : $ { { secrets . bintrayApiKey } } https : / / api . bintray . com / content / pauldreik / simdjson - fuzz - corpus / corpus / 0 / corpus / valgrind . tar " ; publish = 1 ; override = 1 " <nl> + else <nl> + echo " not on master , won ' t upload to bintray " <nl> + fi <nl> new file mode 100755 <nl> index 000000000 . . 59c422031 <nl> mmm / dev / null <nl> ppp b / fuzz / build_fuzzer_variants . sh <nl> <nl> + # ! / bin / sh <nl> + # <nl> + # This file builds multiple variants of the fuzzers <nl> + # - different sanitizers <nl> + # - different build options <nl> + # - reproduce build , for running through valgrind <nl> + <nl> + # fail on error <nl> + set - eu <nl> + <nl> + unset CXX CC CFLAGS CXXFLAGS LDFLAGS <nl> + <nl> + # A reproduce build , without avx but otherwise as plain <nl> + # as it gets . No sanitizers or optimization . <nl> + variant = plain - noavx <nl> + if [ ! - d build - $ variant ] ; then <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = Debug \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = On \ <nl> + - DSIMDJSON_DISABLE_AVX = On <nl> + <nl> + ninja <nl> + cd . . <nl> + fi <nl> + <nl> + # A reproduce build as plain as it gets . Everythings tunable is <nl> + # using the defaults . <nl> + variant = plain - normal <nl> + if [ ! - d build - $ variant ] ; then <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = Debug \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = On <nl> + <nl> + ninja <nl> + cd . . <nl> + fi <nl> + <nl> + # a fuzzer with sanitizers , built with avx disabled . <nl> + variant = ossfuzz - noavx <nl> + if [ ! - d build - $ variant ] ; then <nl> + <nl> + export CC = clang <nl> + export CXX = " clang + + " <nl> + export CFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined - mno - avx2 - mno - avx " <nl> + export CXXFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined - mno - avx2 - mno - avx " <nl> + export LIB_FUZZING_ENGINE = " - fsanitize = fuzzer " <nl> + <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = Debug \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = Off \ <nl> + - DSIMDJSON_FUZZ_LDFLAGS = $ LIB_FUZZING_ENGINE \ <nl> + - DSIMDJSON_DISABLE_AVX = On <nl> + <nl> + ninja <nl> + cd . . <nl> + fi <nl> + <nl> + <nl> + # a fuzzer with sanitizers , built with avx disabled . <nl> + variant = ossfuzz - noavx8 <nl> + if [ ! - d build - $ variant ] ; then <nl> + <nl> + export CC = clang - 8 <nl> + export CXX = " clang + + - 8 " <nl> + export CFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined - mno - avx2 - mno - avx " <nl> + export CXXFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined - mno - avx2 - mno - avx " <nl> + export LIB_FUZZING_ENGINE = " - fsanitize = fuzzer " <nl> + <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = Debug \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = Off \ <nl> + - DSIMDJSON_FUZZ_LDFLAGS = $ LIB_FUZZING_ENGINE \ <nl> + - DSIMDJSON_DISABLE_AVX = On <nl> + <nl> + ninja <nl> + cd . . <nl> + fi <nl> + <nl> + # a fuzzer with sanitizers , default built <nl> + variant = ossfuzz - withavx <nl> + if [ ! - d build - $ variant ] ; then <nl> + <nl> + export CC = clang <nl> + export CXX = " clang + + " <nl> + export CFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined " <nl> + export CXXFLAGS = " - fsanitize = fuzzer - no - link , address , undefined - fno - sanitize - recover = undefined " <nl> + export LIB_FUZZING_ENGINE = " - fsanitize = fuzzer " <nl> + <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = Debug \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = Off \ <nl> + - DSIMDJSON_FUZZ_LDFLAGS = $ LIB_FUZZING_ENGINE <nl> + <nl> + ninja <nl> + cd . . <nl> + fi <nl> + <nl> + # a fast fuzzer , for fast exploration <nl> + variant = ossfuzz - fast8 <nl> + if [ ! - d build - $ variant ] ; then <nl> + export CC = clang - 8 <nl> + export CXX = " clang + + - 8 " <nl> + export CFLAGS = " - fsanitize = fuzzer - no - link - O3 - g " <nl> + export CXXFLAGS = " - fsanitize = fuzzer - no - link - O3 - g " <nl> + export LIB_FUZZING_ENGINE = " - fsanitize = fuzzer " <nl> + <nl> + mkdir build - $ variant <nl> + cd build - $ variant <nl> + <nl> + cmake . . \ <nl> + - GNinja \ <nl> + - DCMAKE_BUILD_TYPE = \ <nl> + - DSIMDJSON_BUILD_STATIC = On \ <nl> + - DENABLE_FUZZING = On \ <nl> + - DSIMDJSON_FUZZ_LINKMAIN = Off \ <nl> + - DSIMDJSON_FUZZ_LDFLAGS = $ LIB_FUZZING_ENGINE <nl> + <nl> + ninja <nl> + <nl> + cd . . <nl> + fi <nl> | run short fuzzing and valgrind in github action | simdjson/simdjson | 3fd1c3b64a23b761530bf26f74ba22fafe1bcf17 | 2019-11-11T21:17:32Z |
mmm a / . jenkins / pytorch / build . sh <nl> ppp b / . jenkins / pytorch / build . sh <nl> if ! which conda ; then <nl> fi <nl> <nl> # sccache will fail for CUDA builds if all cores are used for compiling <nl> - if [ [ " $ BUILD_ENVIRONMENT " = = * cuda * ] ] & & which sccache > / dev / null ; then <nl> + # gcc 7 . 2 with sccache seems to have intermittent OOM issue if all cores are used <nl> + if ( [ [ " $ BUILD_ENVIRONMENT " = = * cuda * ] ] | | [ [ " $ BUILD_ENVIRONMENT " = = * gcc7 . 2 * ] ] ) & & which sccache > / dev / null ; then <nl> export MAX_JOBS = ` expr $ ( nproc ) - 1 ` <nl> fi <nl> <nl> | Reduce MAX_JOBS for gcc 7 . 2 build ( ) | pytorch/pytorch | 599d0fac934784ad6c2b9ece5c2118ab3bc9c0ac | 2018-05-16T21:30:09Z |
mmm a / test / distrib / ruby / distribtest . gemspec <nl> ppp b / test / distrib / ruby / distribtest . gemspec <nl> Gem : : Specification . new do | s | <nl> s . platform = Gem : : Platform : : RUBY <nl> <nl> s . add_dependency ' grpc ' , ' > = 0 ' <nl> + s . add_dependency ' public_suffix ' , ' < 3 . 0 ' <nl> + s . add_dependency ' jwt ' , ' < 2 . 0 ' <nl> <nl> s . add_development_dependency ' bundler ' , ' ~ > 1 . 7 ' <nl> end <nl> mmm a / test / distrib / ruby / run_distrib_test . sh <nl> ppp b / test / distrib / ruby / run_distrib_test . sh <nl> set - ex <nl> <nl> cd $ ( dirname $ 0 ) <nl> <nl> + ARCH = $ 1 <nl> + PLATFORM = $ 2 <nl> # Create an indexed local gem source with gRPC gems to test <nl> GEM_SOURCE = . . / . . / . . / gem_source <nl> mkdir - p $ { GEM_SOURCE } / gems <nl> - cp - r $ EXTERNAL_GIT_ROOT / input_artifacts / * . gem $ { GEM_SOURCE } / gems <nl> + cp $ EXTERNAL_GIT_ROOT / input_artifacts / grpc - * $ ARCH - $ PLATFORM . gem $ { GEM_SOURCE } / gems <nl> + if [ [ " $ ( ls $ { GEM_SOURCE } / gems | grep grpc | wc - l ) " ! = 1 ] ] ; then <nl> + echo " Sanity check failed . Copied over more than one grpc gem into the gem source directory . " <nl> + exit 1 <nl> + fi ; <nl> gem install builder <nl> gem generate_index - - directory $ { GEM_SOURCE } <nl> <nl> mmm a / tools / run_tests / artifacts / distribtest_targets . py <nl> ppp b / tools / run_tests / artifacts / distribtest_targets . py <nl> def pre_build_jobspecs ( self ) : <nl> return [ ] <nl> <nl> def build_jobspec ( self ) : <nl> + arch_to_gem_arch = { <nl> + ' x64 ' : ' x86_64 ' , <nl> + ' x86 ' : ' x86 ' , <nl> + } <nl> if not self . platform = = ' linux ' : <nl> raise Exception ( " Not supported yet . " ) <nl> <nl> def build_jobspec ( self ) : <nl> ' tools / dockerfile / distribtest / ruby_ % s_ % s ' % ( <nl> self . docker_suffix , <nl> self . arch ) , <nl> - ' test / distrib / ruby / run_distrib_test . sh ' , <nl> + ' test / distrib / ruby / run_distrib_test . sh % s % s ' % <nl> + ( arch_to_gem_arch [ self . arch ] , self . platform ) , <nl> copy_rel_path = ' test / distrib ' ) <nl> <nl> def __str__ ( self ) : <nl> | Merge pull request from apolcyn / backport_distribtest_fix | grpc/grpc | 82eebafe3f1278f2333745a6bfb1dede6d17079f | 2018-01-05T01:10:47Z |
mmm a / src / python / grpcio_tests / tests / reflection / _reflection_servicer_test . py <nl> ppp b / src / python / grpcio_tests / tests / reflection / _reflection_servicer_test . py <nl> def _file_descriptor_to_proto ( descriptor ) : <nl> <nl> class ReflectionServicerTest ( unittest . TestCase ) : <nl> <nl> - # NOTE ( lidiz ) Bazel + Python 3 will result in creating two different <nl> - # instance of DESCRIPTOR for each message . So , the equal comparision <nl> - # between protobuf returned by stub and manually crafted protobuf will <nl> - # always fail . <nl> + # TODO ( https : / / github . com / grpc / grpc / issues / 17844 ) <nl> + # Bazel + Python 3 will result in creating two different instance of <nl> + # DESCRIPTOR for each message . So , the equal comparision between protobuf <nl> + # returned by stub and manually crafted protobuf will always fail . <nl> def _assert_sequence_of_proto_equal ( self , x , y ) : <nl> self . assertSequenceEqual ( <nl> list ( map ( lambda x : x . SerializeToString ( ) , x ) ) , <nl> | Point the hack of proto message comparison to new issue | grpc/grpc | fcbb126bafe5f791965c094d1bda881237f13924 | 2019-01-28T22:56:52Z |
mmm a / dlib / image_keypoint / hog . h <nl> ppp b / dlib / image_keypoint / hog . h <nl> namespace dlib <nl> hist_cells . clear ( ) ; <nl> } <nl> <nl> + void copy_configuration ( <nl> + const hog_image & <nl> + ) { } <nl> + <nl> template < <nl> typename image_type <nl> > <nl> mmm a / dlib / image_keypoint / hog_abstract . h <nl> ppp b / dlib / image_keypoint / hog_abstract . h <nl> namespace dlib <nl> - this object will have its initial value <nl> ! * / <nl> <nl> + void copy_configuration ( <nl> + const hog_image & item <nl> + ) ; <nl> + / * ! <nl> + ensures <nl> + - copies all the state information of item into * this except for state <nl> + information populated by load ( ) . More precisely , given two hog_image <nl> + objects H1 and H2 , the following sequence of instructions should always <nl> + result in both of them having the exact same state . <nl> + H2 . copy_configuration ( H1 ) ; <nl> + H1 . load ( img ) ; <nl> + H2 . load ( img ) ; <nl> + ! * / <nl> + <nl> template < <nl> typename image_type <nl> > <nl> | Added a copy_configuration ( ) routine to the hog_image . | davisking/dlib | 40579234b66b102d5e6b441e0d1dd967bd66e7c8 | 2011-09-04T14:27:57Z |
mmm a / src / qt / bitcoinamountfield . cpp <nl> ppp b / src / qt / bitcoinamountfield . cpp <nl> <nl> # include < QKeyEvent > <nl> # include < qmath . h > / / for qPow ( ) <nl> <nl> - BitcoinAmountField : : BitcoinAmountField ( QWidget * parent ) : <nl> - QWidget ( parent ) , amount ( 0 ) , currentUnit ( - 1 ) <nl> + BitcoinAmountField : : BitcoinAmountField ( QWidget * parent ) : <nl> + QWidget ( parent ) , <nl> + amount ( 0 ) , <nl> + currentUnit ( - 1 ) <nl> { <nl> amount = new QDoubleSpinBox ( this ) ; <nl> amount - > setLocale ( QLocale : : c ( ) ) ; <nl> mmm a / src / qt / editaddressdialog . cpp <nl> ppp b / src / qt / editaddressdialog . cpp <nl> <nl> <nl> EditAddressDialog : : EditAddressDialog ( Mode mode , QWidget * parent ) : <nl> QDialog ( parent ) , <nl> - ui ( new Ui : : EditAddressDialog ) , mapper ( 0 ) , mode ( mode ) , model ( 0 ) <nl> + ui ( new Ui : : EditAddressDialog ) , <nl> + mapper ( 0 ) , <nl> + mode ( mode ) , <nl> + model ( 0 ) <nl> { <nl> ui - > setupUi ( this ) ; <nl> <nl> mmm a / src / qt / macdockiconhandler . mm <nl> ppp b / src / qt / macdockiconhandler . mm <nl> <nl> + / / Copyright ( c ) 2011 - 2013 The Bitcoin Core developers <nl> + / / Distributed under the MIT / X11 software license , see the accompanying <nl> + / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + <nl> # include " macdockiconhandler . h " <nl> <nl> + # include < QImageWriter > <nl> # include < QMenu > <nl> - # include < QWidget > <nl> # include < QTemporaryFile > <nl> - # include < QImageWriter > <nl> + # include < QWidget > <nl> <nl> # undef slots <nl> # include < Cocoa / Cocoa . h > <nl> mmm a / src / qt / macnotificationhandler . mm <nl> ppp b / src / qt / macnotificationhandler . mm <nl> <nl> + / / Copyright ( c ) 2011 - 2013 The Bitcoin Core developers <nl> + / / Distributed under the MIT / X11 software license , see the accompanying <nl> + / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + <nl> # include " macnotificationhandler . h " <nl> <nl> # undef slots <nl> mmm a / src / qt / receivecoinsdialog . h <nl> ppp b / src / qt / receivecoinsdialog . h <nl> namespace Ui { <nl> } <nl> class WalletModel ; <nl> class OptionsModel ; <nl> + <nl> QT_BEGIN_NAMESPACE <nl> class QModelIndex ; <nl> QT_END_NAMESPACE <nl> mmm a / src / qt / walletmodel . cpp <nl> ppp b / src / qt / walletmodel . cpp <nl> <nl> <nl> # include " addresstablemodel . h " <nl> # include " guiconstants . h " <nl> - # include " transactiontablemodel . h " <nl> # include " recentrequeststablemodel . h " <nl> + # include " transactiontablemodel . h " <nl> <nl> # include " base58 . h " <nl> # include " db . h " <nl> mmm a / src / qt / walletmodel . h <nl> ppp b / src / qt / walletmodel . h <nl> <nl> <nl> class AddressTableModel ; <nl> class OptionsModel ; <nl> - class TransactionTableModel ; <nl> class RecentRequestsTableModel ; <nl> + class TransactionTableModel ; <nl> class WalletModelTransaction ; <nl> <nl> class CCoinControl ; <nl> mmm a / src / qt / walletmodeltransaction . h <nl> ppp b / src / qt / walletmodeltransaction . h <nl> class WalletModelTransaction <nl> CWalletTx * walletTransaction ; <nl> CReserveKey * keyChange ; <nl> qint64 fee ; <nl> - <nl> - public slots : <nl> - <nl> } ; <nl> <nl> # endif / / WALLETMODELTRANSACTION_H <nl> | [ Qt ] style - police , add missing license headers | bitcoin/bitcoin | 6c1bf199ca25809b0e6323a4dcbe5be97ce84cd9 | 2013-12-17T06:56:40Z |
mmm a / include / grpc / support / time . h <nl> ppp b / include / grpc / support / time . h <nl> typedef enum { <nl> typedef struct gpr_timespec { <nl> time_t tv_sec ; <nl> int tv_nsec ; <nl> + / * * Against which clock was this time measured ? ( or GPR_TIMESPAN if <nl> + this is a relative time meaure ) * / <nl> gpr_clock_type clock_type ; <nl> } gpr_timespec ; <nl> <nl> | Update doc | grpc/grpc | ec6a7fdef95e7c11d2ddef1c9ed3bc59c389f6ac | 2015-07-13T16:53:26Z |
mmm a / test / core / fling / client . c <nl> ppp b / test / core / fling / client . c <nl> static void step_ping_pong_request ( void ) { <nl> grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> + grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> grpc_call_destroy ( call ) ; <nl> call = NULL ; <nl> } <nl> | Merge pull request from vjpai / flingfix | grpc/grpc | 885104b2b54952ef93d209a6fa9f7614ad4bd3a2 | 2015-02-04T20:22:47Z |
mmm a / stdlib / public / core / StringIndex . swift <nl> ppp b / stdlib / public / core / StringIndex . swift <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> extension String { <nl> + / / / A position of a character or code unit in a string . <nl> public struct Index { <nl> internal var _compoundOffset : UInt64 <nl> internal var _cache : _Cache <nl> extension String . Index : Comparable { <nl> extension String . Index { <nl> internal typealias _Self = String . Index <nl> <nl> - public init ( encodedOffset o : Int ) { <nl> - _compoundOffset = UInt64 ( o < < _Self . _strideBits ) <nl> + / / / Creates a new index at the specified UTF - 16 offset . <nl> + / / / <nl> + / / / - Parameter offset : An offset in UTF - 16 code units . <nl> + public init ( encodedOffset offset : Int ) { <nl> + _compoundOffset = UInt64 ( offset < < _Self . _strideBits ) <nl> _cache = . utf16 <nl> } <nl> <nl> extension String . Index { <nl> _compoundOffset = UInt64 ( x < < _Self . _strideBits ) <nl> } <nl> <nl> + / / / The offset into a string ' s UTF - 16 encoding for this index . <nl> public var encodedOffset : Int { <nl> return Int ( _compoundOffset > > numericCast ( _Self . _strideBits ) ) <nl> } <nl> | [ stdlib ] Minimal docs for the new string index | apple/swift | b9f3a2ae478890db747642ae97ea3f7928c39f8f | 2017-07-07T13:15:24Z |
mmm a / depends / packages / libevent . mk <nl> ppp b / depends / packages / libevent . mk <nl> $ ( package ) _version = 2 . 0 . 22 <nl> $ ( package ) _download_path = https : / / github . com / libevent / libevent / releases / download / release - 2 . 0 . 22 - stable <nl> $ ( package ) _file_name = $ ( package ) - $ ( $ ( package ) _version ) - stable . tar . gz <nl> $ ( package ) _sha256_hash = 71c2c49f0adadacfdbe6332a372c38cf9c8b7895bb73dabeaa53cdcc1d4e1fa3 <nl> - $ ( package ) _patches = reuseaddr . patch <nl> + $ ( package ) _patches = reuseaddr . patch libevent - 2 - fixes . patch <nl> <nl> define $ ( package ) _preprocess_cmds <nl> - patch - p1 < $ ( $ ( package ) _patch_dir ) / reuseaddr . patch <nl> + patch - p1 < $ ( $ ( package ) _patch_dir ) / reuseaddr . patch & & \ <nl> + patch - p1 < $ ( $ ( package ) _patch_dir ) / libevent - 2 - fixes . patch <nl> endef <nl> <nl> define $ ( package ) _set_vars <nl> new file mode 100644 <nl> index 000000000000 . . 79fec8a48851 <nl> mmm / dev / null <nl> ppp b / depends / patches / libevent / libevent - 2 - fixes . patch <nl> <nl> + mmm a / util - internal . h 2013 - 11 - 01 12 : 18 : 57 . 000000000 - 0600 <nl> ppp + b / util - internal . h 2015 - 07 - 20 20 : 19 : 43 . 199560900 - 0500 <nl> + HANDLE evutil_load_windows_system_librar <nl> + <nl> + # if defined ( __STDC__ ) & & defined ( __STDC_VERSION__ ) <nl> + # if ( __STDC_VERSION__ > = 199901L ) <nl> + - # define EV_SIZE_FMT " % zu " <nl> + - # define EV_SSIZE_FMT " % zd " <nl> + + # if defined ( _MSC_VER ) | | defined ( __MINGW32__ ) | | defined ( __MINGW64__ ) <nl> + + # define EV_SIZE_FMT " % Iu " <nl> + + # define EV_SSIZE_FMT " % Id " <nl> + + # else <nl> + + # define EV_SIZE_FMT " % zu " <nl> + + # define EV_SSIZE_FMT " % zd " <nl> + + # endif <nl> + # define EV_SIZE_ARG ( x ) ( x ) <nl> + # define EV_SSIZE_ARG ( x ) ( x ) <nl> + # endif <nl> | depends : Add libevent compatibility patch for windows | bitcoin/bitcoin | 64047f8e7feb518fc2fa79feee1af983798883cc | 2016-09-14T17:32:00Z |
mmm a / xbmc / guilib / Texture . cpp <nl> ppp b / xbmc / guilib / Texture . cpp <nl> bool CBaseTexture : : LoadFromFileInternal ( const std : : string & texturePath , unsigned <nl> return false ; <nl> <nl> return LoadFromMemory ( xbtFile . GetImageWidth ( ) , xbtFile . GetImageHeight ( ) , 0 , xbtFile . GetImageFormat ( ) , <nl> - xbtFile . HasImageAlpha ( ) , reinterpret_cast < unsigned char * > ( buf . get ( ) ) ) ; <nl> + xbtFile . HasImageAlpha ( ) , reinterpret_cast < const unsigned char * > ( buf . get ( ) ) ) ; <nl> } <nl> <nl> IImage * pImage ; <nl> bool CBaseTexture : : LoadIImage ( IImage * pImage , unsigned char * buffer , unsigned in <nl> return false ; <nl> } <nl> <nl> - bool CBaseTexture : : LoadFromMemory ( unsigned int width , unsigned int height , unsigned int pitch , unsigned int format , bool hasAlpha , unsigned char * pixels ) <nl> + bool CBaseTexture : : LoadFromMemory ( unsigned int width , unsigned int height , unsigned int pitch , unsigned int format , bool hasAlpha , const unsigned char * pixels ) <nl> { <nl> m_imageWidth = m_originalWidth = width ; <nl> m_imageHeight = m_originalHeight = height ; <nl> mmm a / xbmc / guilib / Texture . h <nl> ppp b / xbmc / guilib / Texture . h <nl> class CBaseTexture <nl> static CBaseTexture * LoadFromFileInMemory ( unsigned char * buffer , size_t bufferSize , const std : : string & mimeType , <nl> unsigned int idealWidth = 0 , unsigned int idealHeight = 0 ) ; <nl> <nl> - bool LoadFromMemory ( unsigned int width , unsigned int height , unsigned int pitch , unsigned int format , bool hasAlpha , unsigned char * pixels ) ; <nl> + bool LoadFromMemory ( unsigned int width , unsigned int height , unsigned int pitch , unsigned int format , bool hasAlpha , const unsigned char * pixels ) ; <nl> bool LoadPaletted ( unsigned int width , unsigned int height , unsigned int pitch , unsigned int format , const unsigned char * pixels , const COLOR * palette ) ; <nl> <nl> bool HasAlpha ( ) const ; <nl> | Merge pull request from popcornmix / const | xbmc/xbmc | 8056e6f63f305eb65682275c0a02f0c69fb07d18 | 2017-07-22T09:09:15Z |
mmm a / src / system . cpp <nl> ppp b / src / system . cpp <nl> System : : System ( QObject * parent ) : <nl> case QSysInfo : : WV_WINDOWS8 : <nl> m_os . insert ( " version " , " 8 " ) ; <nl> break ; <nl> + case QSysInfo : : WV_WINDOWS8_1 : <nl> + m_os . insert ( " version " , " 8 . 1 " ) ; <nl> + break ; <nl> + case QSysInfo : : WV_WINDOWS10 : <nl> + m_os . insert ( " version " , " 10 " ) ; <nl> + break ; <nl> default : <nl> m_os . insert ( " version " , " unknown " ) ; <nl> break ; <nl> System : : System ( QObject * parent ) : <nl> QString osRelease = getOSRelease ( ) ; <nl> m_os . insert ( " release " , osRelease ) ; <nl> <nl> - int kernelVersionMajor = 0 ; <nl> - QStringList releaseParts = osRelease . split ( ' . ' ) ; <nl> - if ( releaseParts . length ( ) = = 3 ) { <nl> - kernelVersionMajor = releaseParts [ 0 ] . toInt ( ) ; <nl> - } <nl> - <nl> switch ( QSysInfo : : MacintoshVersion ) { <nl> case QSysInfo : : MV_10_3 : <nl> m_os . insert ( " version " , " 10 . 3 ( Panther ) " ) ; <nl> System : : System ( QObject * parent ) : <nl> case QSysInfo : : MV_10_9 : <nl> m_os . insert ( " version " , " 10 . 9 ( Mavericks ) " ) ; <nl> break ; <nl> + case QSysInfo : : MV_10_10 : <nl> + m_os . insert ( " version " , " 10 . 10 ( Yosemite ) " ) ; <nl> + break ; <nl> + case QSysInfo : : MV_10_11 : <nl> + m_os . insert ( " version " , " 10 . 11 ( El Capitan ) " ) ; <nl> + break ; <nl> default : <nl> - / / Deduce OS X version from the kernel version . <nl> - / / This is only used for version not yet recognized by Qt <nl> - / / ( there is no associated QSysInfo : : MV_ enum ) . <nl> - switch ( kernelVersionMajor ) { <nl> - case 14 : <nl> - m_os . insert ( " version " , " 10 . 10 ( Yosemite ) " ) ; <nl> - break ; <nl> - default : <nl> - m_os . insert ( " version " , " unknown " ) ; <nl> - break ; <nl> - } <nl> + m_os . insert ( " version " , " unknown " ) ; <nl> break ; <nl> } <nl> # elif defined ( Q_OS_LINUX ) <nl> | Update information about platforms . | ariya/phantomjs | c7d7c656b3924e08c5488a58165289fbb1a512bb | 2015-12-23T13:43:10Z |
mmm a / src / compiler / compilation - dependencies . cc <nl> ppp b / src / compiler / compilation - dependencies . cc <nl> namespace internal { <nl> namespace compiler { <nl> <nl> CompilationDependencies : : CompilationDependencies ( Isolate * isolate , Zone * zone ) <nl> - : zone_ ( zone ) , dependencies_ ( zone ) { } <nl> + : zone_ ( zone ) , dependencies_ ( zone ) , isolate_ ( isolate ) { } <nl> <nl> class CompilationDependencies : : Dependency : public ZoneObject { <nl> public : <nl> bool CompilationDependencies : : Commit ( Handle < Code > code ) { <nl> } <nl> dep - > Install ( MaybeObjectHandle : : Weak ( code ) ) ; <nl> } <nl> - SLOW_DCHECK ( AreValid ( ) ) ; <nl> + <nl> + if ( FLAG_stress_gc_during_compilation ) { <nl> + isolate_ - > heap ( ) - > PreciseCollectAllGarbage ( <nl> + Heap : : kNoGCFlags , GarbageCollectionReason : : kTesting , <nl> + kGCCallbackFlagForced ) ; <nl> + if ( ! AreValid ( ) ) { <nl> + dependencies_ . clear ( ) ; <nl> + return false ; <nl> + } <nl> + } <nl> <nl> dependencies_ . clear ( ) ; <nl> return true ; <nl> mmm a / src / compiler / compilation - dependencies . h <nl> ppp b / src / compiler / compilation - dependencies . h <nl> class V8_EXPORT_PRIVATE CompilationDependencies : public ZoneObject { <nl> private : <nl> Zone * zone_ ; <nl> ZoneForwardList < Dependency * > dependencies_ ; <nl> + Isolate * isolate_ ; <nl> } ; <nl> <nl> } / / namespace compiler <nl> mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_BOOL ( turbo_rewrite_far_jumps , true , <nl> " rewrite far to near jumps ( ia32 , x64 ) " ) <nl> DEFINE_BOOL ( experimental_inline_promise_constructor , true , <nl> " inline the Promise constructor in TurboFan " ) <nl> + DEFINE_BOOL ( <nl> + stress_gc_during_compilation , false , <nl> + " simulate GC / compiler thread race related to https : / / crbug . com / v8 / 8520 " ) <nl> <nl> # ifdef DISABLE_UNTRUSTED_CODE_MITIGATIONS <nl> # define V8_DEFAULT_UNTRUSTED_CODE_MITIGATIONS false <nl> mmm a / test / cctest / cctest . status <nl> ppp b / test / cctest / cctest . status <nl> <nl> ' test - heap - profiler / SamplingHeapProfiler ' : [ SKIP ] , <nl> } ] , # variant = = stress_incremental_marking <nl> <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # The test relies on deterministic compilation . <nl> + [ ' variant = = stress_background_compile ' , { <nl> + ' test - compiler / DecideToPretenureDuringCompilation ' : [ SKIP ] , <nl> + } ] , # variant = = stress_background_compile <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> [ ' variant = = no_wasm_traps ' , { <nl> ' test - accessors / * ' : [ SKIP ] , <nl> mmm a / test / cctest / test - compiler . cc <nl> ppp b / test / cctest / test - compiler . cc <nl> TEST ( DeepEagerCompilationPeakMemory ) { <nl> CHECK_LE ( peak_mem_4 - peak_mem_3 , peak_mem_3 ) ; <nl> } <nl> <nl> + / / TODO ( mslekova ) : Remove the duplication with test - heap . cc <nl> + static int AllocationSitesCount ( Heap * heap ) { <nl> + int count = 0 ; <nl> + for ( Object * site = heap - > allocation_sites_list ( ) ; <nl> + site - > IsAllocationSite ( ) ; ) { <nl> + AllocationSite * cur = AllocationSite : : cast ( site ) ; <nl> + CHECK ( cur - > HasWeakNext ( ) ) ; <nl> + site = cur - > weak_next ( ) ; <nl> + count + + ; <nl> + } <nl> + return count ; <nl> + } <nl> + <nl> + / / This test simulates a specific race - condition if GC is triggered just <nl> + / / before CompilationDependencies : : Commit is finished , and this changes <nl> + / / the pretenuring decision , thus causing a deoptimization . <nl> + TEST ( DecideToPretenureDuringCompilation ) { <nl> + / / The test makes use of optimization and relies on deterministic <nl> + / / compilation . <nl> + if ( ! i : : FLAG_opt | | i : : FLAG_always_opt | | <nl> + i : : FLAG_stress_incremental_marking | | i : : FLAG_optimize_for_size <nl> + # ifdef ENABLE_MINOR_MC <nl> + | | i : : FLAG_minor_mc <nl> + # endif <nl> + ) <nl> + return ; <nl> + <nl> + FLAG_stress_gc_during_compilation = true ; <nl> + FLAG_allow_natives_syntax = true ; <nl> + FLAG_allocation_site_pretenuring = true ; <nl> + <nl> + / / We want to trigger exactly 1 optimization . <nl> + FLAG_use_osr = false ; <nl> + <nl> + / / We ' ll do manual initialization . <nl> + ManualGCScope manual_gc_scope ; <nl> + v8 : : Isolate : : CreateParams create_params ; <nl> + <nl> + / / This setting ensures Heap : : MaximumSizeScavenge will return ` true ` . <nl> + / / We need to initialize the heap with at least 1 page , while keeping the <nl> + / / limit low , to ensure the new space fills even on 32 - bit architectures . <nl> + create_params . constraints . set_max_semi_space_size_in_kb ( Page : : kPageSize / <nl> + 1024 ) ; <nl> + create_params . array_buffer_allocator = CcTest : : array_buffer_allocator ( ) ; <nl> + v8 : : Isolate * isolate = v8 : : Isolate : : New ( create_params ) ; <nl> + <nl> + isolate - > Enter ( ) ; <nl> + { <nl> + i : : Isolate * i_isolate = reinterpret_cast < i : : Isolate * > ( isolate ) ; <nl> + Heap * heap = i_isolate - > heap ( ) ; <nl> + GlobalHandles * global_handles = i_isolate - > global_handles ( ) ; <nl> + HandleScope handle_scope ( i_isolate ) ; <nl> + <nl> + / / The allocation site at the head of the list is ours . <nl> + Handle < AllocationSite > site ; <nl> + { <nl> + LocalContext context ( isolate ) ; <nl> + v8 : : HandleScope scope ( context - > GetIsolate ( ) ) ; <nl> + <nl> + int count = AllocationSitesCount ( heap ) ; <nl> + CompileRun ( <nl> + " let arr = [ ] ; " <nl> + " function foo ( shouldKeep ) { " <nl> + " let local_array = new Array ( ) ; " <nl> + " if ( shouldKeep ) arr . push ( local_array ) ; " <nl> + " } " <nl> + " function bar ( shouldKeep ) { " <nl> + " for ( let i = 0 ; i < 10000 ; i + + ) { " <nl> + " foo ( shouldKeep ) ; " <nl> + " } " <nl> + " } " <nl> + " bar ( ) ; " ) ; <nl> + <nl> + / / This number should be > = kPretenureRatio * 10000 , <nl> + / / where 10000 is the number of iterations in ` bar ` , <nl> + / / in order to make the ratio in DigestPretenuringFeedback close to 1 . <nl> + const int memento_found_bump = 8500 ; <nl> + <nl> + / / One allocation site should have been created . <nl> + int new_count = AllocationSitesCount ( heap ) ; <nl> + CHECK_EQ ( new_count , ( count + 1 ) ) ; <nl> + site = Handle < AllocationSite > : : cast ( global_handles - > Create ( <nl> + AllocationSite : : cast ( heap - > allocation_sites_list ( ) ) ) ) ; <nl> + site - > set_memento_found_count ( memento_found_bump ) ; <nl> + <nl> + CompileRun ( " % OptimizeFunctionOnNextCall ( bar ) ; " ) ; <nl> + CompileRun ( " bar ( true ) ; " ) ; <nl> + <nl> + / / The last call should have caused ` foo ` to bail out of compilation <nl> + / / due to dependency change ( the pretenuring decision in this case ) . <nl> + / / This will cause recompilation . <nl> + <nl> + / / Check ` bar ` can get optimized again , meaning the compiler state is <nl> + / / recoverable from this point . <nl> + CompileRun ( " % OptimizeFunctionOnNextCall ( bar ) ; " ) ; <nl> + CompileRun ( " bar ( ) ; " ) ; <nl> + <nl> + Handle < Object > foo_obj = <nl> + JSReceiver : : GetProperty ( i_isolate , i_isolate - > global_object ( ) , " bar " ) <nl> + . ToHandleChecked ( ) ; <nl> + Handle < JSFunction > bar = Handle < JSFunction > : : cast ( foo_obj ) ; <nl> + <nl> + CHECK ( bar - > IsOptimized ( ) ) ; <nl> + } <nl> + } <nl> + isolate - > Exit ( ) ; <nl> + isolate - > Dispose ( ) ; <nl> + } <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl> | [ test ] Fix flaky wasm test and add stable regression test | v8/v8 | 3dbb374938c8c80474f4e4373ea5fd1827f830c2 | 2018-12-14T09:32:59Z |
mmm a / cocos / editor - support / cocostudio / CCArmatureDataManager . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCArmatureDataManager . cpp <nl> ArmatureDataManager : : ArmatureDataManager ( void ) <nl> <nl> ArmatureDataManager : : ~ ArmatureDataManager ( void ) <nl> { <nl> - removeAll ( ) ; <nl> + if ( _animationDatas ) <nl> + { <nl> + _animationDatas - > removeAllObjects ( ) ; <nl> + } <nl> + if ( _armarureDatas ) <nl> + { <nl> + _armarureDatas - > removeAllObjects ( ) ; <nl> + } <nl> + <nl> + if ( _textureDatas ) <nl> + { <nl> + _textureDatas - > removeAllObjects ( ) ; <nl> + } <nl> + <nl> + _relativeDatas . clear ( ) ; <nl> <nl> CC_SAFE_DELETE ( _animationDatas ) ; <nl> CC_SAFE_DELETE ( _armarureDatas ) ; <nl> bool ArmatureDataManager : : init ( ) <nl> return bRet ; <nl> } <nl> <nl> - void ArmatureDataManager : : addArmatureData ( const char * id , ArmatureData * armatureData ) <nl> + void ArmatureDataManager : : removeArmatureFileInfo ( const char * configFilePath ) <nl> + { <nl> + if ( RelativeData * data = getRelativeData ( configFilePath ) ) <nl> + { <nl> + for ( std : : vector < std : : string > : : iterator i = data - > armatures . begin ( ) ; i ! = data - > armatures . end ( ) ; i + + ) <nl> + { <nl> + removeArmatureData ( i - > c_str ( ) ) ; <nl> + } <nl> + <nl> + for ( std : : vector < std : : string > : : iterator i = data - > animations . begin ( ) ; i ! = data - > animations . end ( ) ; i + + ) <nl> + { <nl> + removeAnimationData ( i - > c_str ( ) ) ; <nl> + } <nl> + <nl> + for ( std : : vector < std : : string > : : iterator i = data - > textures . begin ( ) ; i ! = data - > textures . end ( ) ; i + + ) <nl> + { <nl> + removeTextureData ( i - > c_str ( ) ) ; <nl> + } <nl> + <nl> + for ( std : : vector < std : : string > : : iterator i = data - > plistFiles . begin ( ) ; i ! = data - > plistFiles . end ( ) ; i + + ) <nl> + { <nl> + SpriteFrameCache : : getInstance ( ) - > removeSpriteFramesFromFile ( i - > c_str ( ) ) ; <nl> + } <nl> + <nl> + _relativeDatas . erase ( configFilePath ) ; <nl> + DataReaderHelper : : sharedDataReaderHelper ( ) - > removeConfigFile ( configFilePath ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void ArmatureDataManager : : addArmatureData ( const char * id , ArmatureData * armatureData , const char * configFilePath ) <nl> { <nl> if ( _armarureDatas ) <nl> { <nl> + if ( RelativeData * data = getRelativeData ( configFilePath ) ) <nl> + { <nl> + data - > armatures . push_back ( id ) ; <nl> + } <nl> + <nl> _armarureDatas - > setObject ( armatureData , id ) ; <nl> } <nl> } <nl> void ArmatureDataManager : : removeArmatureData ( const char * id ) <nl> } <nl> } <nl> <nl> - void ArmatureDataManager : : addAnimationData ( const char * id , AnimationData * animationData ) <nl> + void ArmatureDataManager : : addAnimationData ( const char * id , AnimationData * animationData , const char * configFilePath ) <nl> { <nl> if ( _animationDatas ) <nl> { <nl> + if ( RelativeData * data = getRelativeData ( configFilePath ) ) <nl> + { <nl> + data - > animations . push_back ( id ) ; <nl> + } <nl> + <nl> _animationDatas - > setObject ( animationData , id ) ; <nl> } <nl> } <nl> void ArmatureDataManager : : removeAnimationData ( const char * id ) <nl> } <nl> } <nl> <nl> - void ArmatureDataManager : : addTextureData ( const char * id , TextureData * textureData ) <nl> + void ArmatureDataManager : : addTextureData ( const char * id , TextureData * textureData , const char * configFilePath ) <nl> { <nl> if ( _textureDatas ) <nl> { <nl> + if ( RelativeData * data = getRelativeData ( configFilePath ) ) <nl> + { <nl> + data - > textures . push_back ( id ) ; <nl> + } <nl> + <nl> _textureDatas - > setObject ( textureData , id ) ; <nl> } <nl> } <nl> void ArmatureDataManager : : removeTextureData ( const char * id ) <nl> <nl> void ArmatureDataManager : : addArmatureFileInfo ( const char * configFilePath ) <nl> { <nl> + addRelativeData ( configFilePath ) ; <nl> + <nl> _autoLoadSpriteFile = true ; <nl> DataReaderHelper : : getInstance ( ) - > addDataFromFile ( configFilePath ) ; <nl> } <nl> <nl> void ArmatureDataManager : : addArmatureFileInfoAsync ( const char * configFilePath , Object * target , SEL_SCHEDULE selector ) <nl> { <nl> + addRelativeData ( configFilePath ) ; <nl> + <nl> _autoLoadSpriteFile = true ; <nl> DataReaderHelper : : getInstance ( ) - > addDataFromFileAsync ( " " , " " , configFilePath , target , selector ) ; <nl> } <nl> <nl> void ArmatureDataManager : : addArmatureFileInfo ( const char * imagePath , const char * plistPath , const char * configFilePath ) <nl> { <nl> + addRelativeData ( configFilePath ) ; <nl> + <nl> _autoLoadSpriteFile = false ; <nl> DataReaderHelper : : getInstance ( ) - > addDataFromFile ( configFilePath ) ; <nl> addSpriteFrameFromFile ( plistPath , imagePath ) ; <nl> void ArmatureDataManager : : addArmatureFileInfo ( const char * imagePath , const char <nl> <nl> void ArmatureDataManager : : addArmatureFileInfoAsync ( const char * imagePath , const char * plistPath , const char * configFilePath , Object * target , SEL_SCHEDULE selector ) <nl> { <nl> + addRelativeData ( configFilePath ) ; <nl> + <nl> _autoLoadSpriteFile = false ; <nl> DataReaderHelper : : getInstance ( ) - > addDataFromFileAsync ( imagePath , plistPath , configFilePath , target , selector ) ; <nl> addSpriteFrameFromFile ( plistPath , imagePath ) ; <nl> } <nl> <nl> - void ArmatureDataManager : : addSpriteFrameFromFile ( const char * plistPath , const char * imagePath ) <nl> + void ArmatureDataManager : : addSpriteFrameFromFile ( const char * plistPath , const char * imagePath , const char * configFilePath ) <nl> { <nl> - SpriteFrameCacheHelper : : getInstance ( ) - > addSpriteFrameFromFile ( plistPath , imagePath ) ; <nl> - } <nl> - <nl> - <nl> - void ArmatureDataManager : : removeAll ( ) <nl> - { <nl> - if ( _animationDatas ) <nl> - { <nl> - _animationDatas - > removeAllObjects ( ) ; <nl> - } <nl> - if ( _armarureDatas ) <nl> + if ( RelativeData * data = getRelativeData ( configFilePath ) ) <nl> { <nl> - _armarureDatas - > removeAllObjects ( ) ; <nl> + data - > plistFiles . push_back ( plistPath ) ; <nl> } <nl> - <nl> - if ( _textureDatas ) <nl> - { <nl> - _textureDatas - > removeAllObjects ( ) ; <nl> - } <nl> - <nl> - DataReaderHelper : : clear ( ) ; <nl> + SpriteFrameCacheHelper : : getInstance ( ) - > addSpriteFrameFromFile ( plistPath , imagePath ) ; <nl> } <nl> <nl> + <nl> bool ArmatureDataManager : : isAutoLoadSpriteFile ( ) <nl> { <nl> return _autoLoadSpriteFile ; <nl> Dictionary * ArmatureDataManager : : getTextureDatas ( ) const <nl> return _textureDatas ; <nl> } <nl> <nl> + void CCArmatureDataManager : : addRelativeData ( const char * configFilePath ) <nl> + { <nl> + if ( _relativeDatas . find ( configFilePath ) = = _relativeDatas . end ( ) ) <nl> + { <nl> + _relativeDatas [ configFilePath ] = RelativeData ( ) ; <nl> + } <nl> + } <nl> + <nl> + RelativeData * CCArmatureDataManager : : getRelativeData ( const char * configFilePath ) <nl> + { <nl> + return & _relativeDatas [ configFilePath ] ; <nl> + } <nl> + <nl> } <nl> mmm a / cocos / editor - support / cocostudio / CCArmatureDataManager . h <nl> ppp b / cocos / editor - support / cocostudio / CCArmatureDataManager . h <nl> THE SOFTWARE . <nl> <nl> namespace cocostudio { <nl> <nl> + struct RelativeData <nl> + { <nl> + std : : vector < std : : string > plistFiles ; <nl> + std : : vector < std : : string > armatures ; <nl> + std : : vector < std : : string > animations ; <nl> + std : : vector < std : : string > textures ; <nl> + } ; <nl> + <nl> / * * <nl> * @ brief format and manage armature configuration and armature animation <nl> * / <nl> class ArmatureDataManager : public cocos2d : : Object <nl> * @ param id The id of the armature data <nl> * @ param armatureData ArmatureData * <nl> * / <nl> - void addArmatureData ( const char * id , ArmatureData * armatureData ) ; <nl> + void addArmatureData ( const char * id , ArmatureData * armatureData , const char * configFilePath = " " ) ; <nl> <nl> / * * <nl> * @ brief get armature data <nl> class ArmatureDataManager : public cocos2d : : Object <nl> * @ param id the id of the animation data <nl> * @ return AnimationData * <nl> * / <nl> - void addAnimationData ( const char * id , AnimationData * animationData ) ; <nl> + void addAnimationData ( const char * id , AnimationData * animationData , const char * configFilePath = " " ) ; <nl> <nl> / * * <nl> * @ brief get animation data from _animationDatas ( Dictionary ) <nl> class ArmatureDataManager : public cocos2d : : Object <nl> * @ param id the id of the texture data <nl> * @ return TextureData * <nl> * / <nl> - void addTextureData ( const char * id , TextureData * textureData ) ; <nl> + void addTextureData ( const char * id , TextureData * textureData , const char * configFilePath = " " ) ; <nl> <nl> / * * <nl> * @ brief get texture data <nl> class ArmatureDataManager : public cocos2d : : Object <nl> / * * <nl> * @ brief Add sprite frame to CCSpriteFrameCache , it will save display name and it ' s relative image name <nl> * / <nl> - void addSpriteFrameFromFile ( const char * plistPath , const char * imagePath ) ; <nl> + void addSpriteFrameFromFile ( const char * plistPath , const char * imagePath , const char * configFilePath = " " ) ; <nl> <nl> + virtual void removeArmatureFileInfo ( const char * configFilePath ) ; <nl> <nl> - / * * <nl> - * @ brief Clear the data in the _armarureDatas and _animationDatas , and set _armarureDatas and _animationDatas to NULL <nl> - * / <nl> - void removeAll ( ) ; <nl> <nl> / * * <nl> * @ brief Juge whether or not need auto load sprite file <nl> class ArmatureDataManager : public cocos2d : : Object <nl> cocos2d : : Dictionary * getArmatureDatas ( ) const ; <nl> cocos2d : : Dictionary * getAnimationDatas ( ) const ; <nl> cocos2d : : Dictionary * getTextureDatas ( ) const ; <nl> + <nl> + protected : <nl> + void addRelativeData ( const char * configFilePath ) ; <nl> + RelativeData * getRelativeData ( const char * configFilePath ) ; <nl> private : <nl> / * * <nl> * @ brief save amature datas <nl> class ArmatureDataManager : public cocos2d : : Object <nl> cocos2d : : Dictionary * _textureDatas ; <nl> <nl> bool _autoLoadSpriteFile ; <nl> + <nl> + std : : map < std : : string , RelativeData > _relativeDatas ; <nl> } ; <nl> <nl> <nl> mmm a / cocos / editor - support / cocostudio / CCArmatureDefine . h <nl> ppp b / cocos / editor - support / cocostudio / CCArmatureDefine . h <nl> THE SOFTWARE . <nl> # define ENABLE_PHYSICS_CHIPMUNK_DETECT 1 <nl> # endif <nl> <nl> + # ifndef ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + # define ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX 0 <nl> + # endif <nl> + <nl> # define CS_RETURN_IF ( cond ) if ( cond ) return <nl> # define CS_RETURN_NULL_IF ( cond ) if ( cond ) return NULL ; <nl> <nl> mmm a / cocos / editor - support / cocostudio / CCColliderDetector . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCColliderDetector . cpp <nl> ColliderBody : : ColliderBody ( ContourData * contourData ) <nl> , _contourData ( contourData ) <nl> { <nl> CC_SAFE_RETAIN ( _contourData ) ; <nl> + <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + _calculatedVertexList = Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _calculatedVertexList ) ; <nl> + # endif <nl> } <nl> # elif ENABLE_PHYSICS_CHIPMUNK_DETECT <nl> <nl> ColliderBody : : ColliderBody ( ContourData * contourData ) <nl> , _contourData ( contourData ) <nl> { <nl> CC_SAFE_RETAIN ( _contourData ) ; <nl> + <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + _calculatedVertexList = Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _calculatedVertexList ) ; <nl> + # endif <nl> } <nl> # endif <nl> <nl> ColliderBody : : ~ ColliderBody ( ) <nl> { <nl> CC_SAFE_RELEASE ( _contourData ) ; <nl> <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + CC_SAFE_RELEASE ( _calculatedVertexList ) ; <nl> + # endif <nl> + <nl> # if ENABLE_PHYSICS_BOX2D_DETECT <nl> CC_SAFE_DELETE ( _filter ) ; <nl> # endif <nl> void ColliderDetector : : addContourData ( ContourData * contourData ) <nl> ColliderBody * colliderBody = new ColliderBody ( contourData ) ; <nl> _colliderBodyList - > addObject ( colliderBody ) ; <nl> colliderBody - > release ( ) ; <nl> + <nl> + <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + CCArray * calculatedVertexList = colliderBody - > getCalculatedVertexList ( ) ; <nl> + <nl> + int num = contourData - > vertexList . count ( ) ; <nl> + for ( int i = 0 ; i < num ; i + + ) <nl> + { <nl> + ContourVertex2 * newVertex = new ContourVertex2 ( 0 , 0 ) ; <nl> + calculatedVertexList - > addObject ( newVertex ) ; <nl> + newVertex - > release ( ) ; <nl> + } <nl> + # endif <nl> } <nl> <nl> void ColliderDetector : : addContourDataList ( Array * contourDataList ) <nl> void ColliderDetector : : updateTransform ( AffineTransform & t ) <nl> int num = contourData - > vertexList . count ( ) ; <nl> ContourVertex2 * * vs = ( ContourVertex2 * * ) contourData - > vertexList . data - > arr ; <nl> <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + ContourVertex2 * * cvs = ( ContourVertex2 * * ) colliderBody - > getCalculatedVertexList ( ) - > data - > arr ; <nl> + # endif <nl> + <nl> for ( int i = 0 ; i < num ; i + + ) <nl> { <nl> helpPoint . setPoint ( vs [ i ] - > x , vs [ i ] - > y ) ; <nl> helpPoint = PointApplyAffineTransform ( helpPoint , t ) ; <nl> <nl> <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + cvs [ i ] - > x = helpPoint . x ; <nl> + cvs [ i ] - > y = helpPoint . y ; <nl> + # endif <nl> + <nl> # if ENABLE_PHYSICS_BOX2D_DETECT <nl> if ( shape ! = NULL ) <nl> { <nl> mmm a / cocos / editor - support / cocostudio / CCColliderDetector . h <nl> ppp b / cocos / editor - support / cocostudio / CCColliderDetector . h <nl> class ColliderBody : public cocos2d : : Object <nl> } <nl> private : <nl> ContourData * _contourData ; <nl> + <nl> + # if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX <nl> + CC_SYNTHESIZE_READONLY ( CCArray * , _calculatedVertexList , CalculatedVertexList ) ; <nl> + # endif <nl> } ; <nl> <nl> / * <nl> mmm a / cocos / editor - support / cocostudio / CCDataReaderHelper . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCDataReaderHelper . cpp <nl> static const char * CONTENT_SCALE = " content_scale " ; <nl> namespace cocostudio { <nl> <nl> <nl> - std : : vector < std : : string > s_arrConfigFileList ; <nl> + <nl> float s_PositionReadScale = 1 ; <nl> float s_ContentScale = 1 ; <nl> static float s_FlashToolVersion = VERSION_2_0 ; <nl> static float s_CocoStudioVersion = VERSION_COMBINED ; <nl> <nl> - static std : : string s_BasefilePath = " " ; <nl> + std : : vector < std : : string > DataReaderHelper : : _configFileList ; <nl> + std : : string DataReaderHelper : : _basefilePath = " " ; <nl> <nl> DataReaderHelper * DataReaderHelper : : _dataReaderHelper = NULL ; <nl> <nl> void DataReaderHelper : : loadData ( ) <nl> _asyncStructQueueMutex . unlock ( ) ; <nl> } <nl> <nl> - / / generate image info <nl> + / / generate data info <nl> DataInfo * pDataInfo = new DataInfo ( ) ; <nl> pDataInfo - > asyncStruct = pAsyncStruct ; <nl> <nl> float DataReaderHelper : : getPositionReadScale ( ) <nl> <nl> void DataReaderHelper : : purge ( ) <nl> { <nl> - DataReaderHelper : : clear ( ) ; <nl> + _configFileList . clear ( ) ; <nl> CC_SAFE_RELEASE_NULL ( _dataReaderHelper ) ; <nl> } <nl> <nl> - void DataReaderHelper : : clear ( ) <nl> - { <nl> - s_arrConfigFileList . clear ( ) ; <nl> - } <nl> <nl> DataReaderHelper : : DataReaderHelper ( ) <nl> : _loadingThread ( nullptr ) <nl> void DataReaderHelper : : addDataFromFile ( const char * filePath ) <nl> / * <nl> * Check if file is already added to ArmatureDataManager , if then return . <nl> * / <nl> - for ( unsigned int i = 0 ; i < s_arrConfigFileList . size ( ) ; i + + ) <nl> + for ( unsigned int i = 0 ; i < _configFileList . size ( ) ; i + + ) <nl> { <nl> - if ( s_arrConfigFileList [ i ] . compare ( filePath ) = = 0 ) <nl> + if ( _configFileList [ i ] . compare ( filePath ) = = 0 ) <nl> { <nl> return ; <nl> } <nl> } <nl> - s_arrConfigFileList . push_back ( filePath ) ; <nl> + _configFileList . push_back ( filePath ) ; <nl> <nl> <nl> / / ! find the base file path <nl> - s_BasefilePath = filePath ; <nl> - size_t pos = s_BasefilePath . find_last_of ( " / " ) ; <nl> + _basefilePath = filePath ; <nl> + size_t pos = _basefilePath . find_last_of ( " / " ) ; <nl> if ( pos ! = std : : string : : npos ) <nl> { <nl> - s_BasefilePath = s_BasefilePath . substr ( 0 , pos + 1 ) ; <nl> + _basefilePath = _basefilePath . substr ( 0 , pos + 1 ) ; <nl> } <nl> else <nl> { <nl> - s_BasefilePath = " " ; <nl> + _basefilePath = " " ; <nl> } <nl> <nl> <nl> void DataReaderHelper : : addDataFromFile ( const char * filePath ) <nl> std : : string fullPath = CCFileUtils : : getInstance ( ) - > fullPathForFilename ( filePath ) ; <nl> const char * pFileContent = ( char * ) CCFileUtils : : getInstance ( ) - > getFileData ( fullPath . c_str ( ) , " r " , & size ) ; <nl> <nl> + DataInfo dataInfo ; <nl> + dataInfo . filename = filePathStr ; <nl> + dataInfo . asyncStruct = NULL ; <nl> + <nl> if ( str . compare ( " . xml " ) = = 0 ) <nl> { <nl> - DataReaderHelper : : addDataFromCache ( pFileContent ) ; <nl> + DataReaderHelper : : addDataFromCache ( pFileContent , & dataInfo ) ; <nl> } <nl> else if ( str . compare ( " . json " ) = = 0 | | str . compare ( " . ExportJson " ) = = 0 ) <nl> { <nl> - DataReaderHelper : : addDataFromJsonCache ( pFileContent ) ; <nl> + DataReaderHelper : : addDataFromJsonCache ( pFileContent , & dataInfo ) ; <nl> } <nl> } <nl> <nl> void DataReaderHelper : : addDataFromFileAsync ( const char * imagePath , const char * p <nl> / * <nl> * Check if file is already added to ArmatureDataManager , if then return . <nl> * / <nl> - for ( unsigned int i = 0 ; i < s_arrConfigFileList . size ( ) ; i + + ) <nl> + for ( unsigned int i = 0 ; i < _configFileList . size ( ) ; i + + ) <nl> { <nl> - if ( s_arrConfigFileList [ i ] . compare ( filePath ) = = 0 ) <nl> + if ( _configFileList [ i ] . compare ( filePath ) = = 0 ) <nl> { <nl> if ( target & & selector ) <nl> { <nl> void DataReaderHelper : : addDataFromFileAsync ( const char * imagePath , const char * p <nl> return ; <nl> } <nl> } <nl> - s_arrConfigFileList . push_back ( filePath ) ; <nl> + _configFileList . push_back ( filePath ) ; <nl> <nl> / / ! find the base file path <nl> std : : string basefilePath = filePath ; <nl> void DataReaderHelper : : addDataAsyncCallBack ( float dt ) <nl> } <nl> <nl> <nl> + void DataReaderHelper : : removeConfigFile ( const char * configFile ) <nl> + { <nl> + std : : vector < std : : string > : : iterator it = _configFileList . end ( ) ; <nl> + for ( std : : vector < std : : string > : : iterator i = _configFileList . begin ( ) ; i ! = _configFileList . end ( ) ; i + + ) <nl> + { <nl> + if ( * i = = configFile ) <nl> + { <nl> + it = i ; <nl> + } <nl> + } <nl> <nl> + if ( it ! = _configFileList . end ( ) ) <nl> + { <nl> + _configFileList . erase ( it ) ; <nl> + } <nl> + } <nl> <nl> <nl> <nl> void DataReaderHelper : : addDataFromCache ( const char * pFileContent , DataInfo * data <nl> { <nl> ArmatureData * armatureData = DataReaderHelper : : decodeArmature ( armatureXML ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> - ArmatureDataManager : : getInstance ( ) - > addArmatureData ( armatureData - > name . c_str ( ) , armatureData ) ; <nl> + ArmatureDataManager : : getInstance ( ) - > addArmatureData ( armatureData - > name . c_str ( ) , armatureData , dataInfo - > filename . c_str ( ) ) ; <nl> armatureData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromCache ( const char * pFileContent , DataInfo * data <nl> while ( animationXML ) <nl> { <nl> AnimationData * animationData = DataReaderHelper : : decodeAnimation ( animationXML ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> - ArmatureDataManager : : getInstance ( ) - > addAnimationData ( animationData - > name . c_str ( ) , animationData ) ; <nl> + ArmatureDataManager : : getInstance ( ) - > addAnimationData ( animationData - > name . c_str ( ) , animationData , dataInfo - > filename . c_str ( ) ) ; <nl> animationData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromCache ( const char * pFileContent , DataInfo * data <nl> { <nl> TextureData * textureData = DataReaderHelper : : decodeTexture ( textureXML ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> - ArmatureDataManager : : getInstance ( ) - > addTextureData ( textureData - > name . c_str ( ) , textureData ) ; <nl> + ArmatureDataManager : : getInstance ( ) - > addTextureData ( textureData - > name . c_str ( ) , textureData , dataInfo - > filename . c_str ( ) ) ; <nl> textureData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> JsonDictionary json ; <nl> json . initWithDescription ( fileContent ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> dataInfo - > contentScale = json . getItemFloatValue ( CONTENT_SCALE , 1 ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> JsonDictionary * armatureDic = json . getSubItemFromArray ( ARMATURE_DATA , i ) ; <nl> ArmatureData * armatureData = decodeArmature ( * armatureDic , dataInfo ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> ArmatureDataManager : : getInstance ( ) - > addArmatureData ( armatureData - > name . c_str ( ) , armatureData ) ; <nl> armatureData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> JsonDictionary * animationDic = json . getSubItemFromArray ( ANIMATION_DATA , i ) ; <nl> AnimationData * animationData = decodeAnimation ( * animationDic , dataInfo ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> ArmatureDataManager : : getInstance ( ) - > addAnimationData ( animationData - > name . c_str ( ) , animationData ) ; <nl> animationData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> JsonDictionary * textureDic = json . getSubItemFromArray ( TEXTURE_DATA , i ) ; <nl> TextureData * textureData = decodeTexture ( * textureDic ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . lock ( ) ; <nl> } <nl> ArmatureDataManager : : getInstance ( ) - > addTextureData ( textureData - > name . c_str ( ) , textureData ) ; <nl> textureData - > release ( ) ; <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> _dataReaderHelper - > _addDataMutex . unlock ( ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> } <nl> <nl> / / Auto load sprite file <nl> - bool autoLoad = dataInfo = = NULL ? ArmatureDataManager : : getInstance ( ) - > isAutoLoadSpriteFile ( ) : dataInfo - > asyncStruct - > autoLoadSpriteFile ; <nl> + bool autoLoad = dataInfo - > asyncStruct = = NULL ? ArmatureDataManager : : getInstance ( ) - > isAutoLoadSpriteFile ( ) : dataInfo - > asyncStruct - > autoLoadSpriteFile ; <nl> if ( autoLoad ) <nl> { <nl> length = json . getArrayItemCount ( CONFIG_FILE_PATH ) ; <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> std : : string filePath = path ; <nl> filePath = filePath . erase ( filePath . find_last_of ( " . " ) ) ; <nl> <nl> - if ( dataInfo ! = NULL ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> dataInfo - > configFileQueue . push ( filePath ) ; <nl> } <nl> void DataReaderHelper : : addDataFromJsonCache ( const char * fileContent , DataInfo * d <nl> std : : string plistPath = filePath + " . plist " ; <nl> std : : string pngPath = filePath + " . png " ; <nl> <nl> - ArmatureDataManager : : getInstance ( ) - > addSpriteFrameFromFile ( ( s_BasefilePath + plistPath ) . c_str ( ) , ( s_BasefilePath + pngPath ) . c_str ( ) ) ; <nl> + ArmatureDataManager : : getInstance ( ) - > addSpriteFrameFromFile ( ( _basefilePath + plistPath ) . c_str ( ) , ( _basefilePath + pngPath ) . c_str ( ) ) ; <nl> } <nl> } <nl> } <nl> DisplayData * DataReaderHelper : : decodeBoneDisplay ( JsonDictionary & json , DataInfo <nl> sdd - > skinData . skewX = dic - > getItemFloatValue ( A_SKEW_X , 0 ) ; <nl> sdd - > skinData . skewY = dic - > getItemFloatValue ( A_SKEW_Y , 0 ) ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> sdd - > skinData . x * = dataInfo - > contentScale ; <nl> sdd - > skinData . y * = dataInfo - > contentScale ; <nl> DisplayData * DataReaderHelper : : decodeBoneDisplay ( JsonDictionary & json , DataInfo <nl> const char * plist = json . getItemStringValue ( A_PLIST ) ; <nl> if ( plist ! = NULL ) <nl> { <nl> - if ( dataInfo ! = NULL ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> static_cast < ParticleDisplayData * > ( displayData ) - > plist = dataInfo - > asyncStruct - > baseFilePath + plist ; <nl> } <nl> else <nl> { <nl> - static_cast < ParticleDisplayData * > ( displayData ) - > plist = s_BasefilePath + plist ; <nl> + static_cast < ParticleDisplayData * > ( displayData ) - > plist = _basefilePath + plist ; <nl> } <nl> } <nl> } <nl> void DataReaderHelper : : decodeNode ( BaseData * node , JsonDictionary & json , DataInfo <nl> node - > x = json . getItemFloatValue ( A_X , 0 ) * s_PositionReadScale ; <nl> node - > y = json . getItemFloatValue ( A_Y , 0 ) * s_PositionReadScale ; <nl> <nl> - if ( dataInfo ) <nl> + if ( dataInfo - > asyncStruct ) <nl> { <nl> node - > x * = dataInfo - > contentScale ; <nl> node - > y * = dataInfo - > contentScale ; <nl> mmm a / cocos / editor - support / cocostudio / CCDataReaderHelper . h <nl> ppp b / cocos / editor - support / cocostudio / CCDataReaderHelper . h <nl> class DataReaderHelper : cocos2d : : Object <nl> AsyncStruct * asyncStruct ; <nl> std : : queue < std : : string > configFileQueue ; <nl> float contentScale ; <nl> + std : : string filename ; <nl> } DataInfo ; <nl> <nl> public : <nl> class DataReaderHelper : cocos2d : : Object <nl> static float getPositionReadScale ( ) ; <nl> <nl> static void purge ( ) ; <nl> - static void clear ( ) ; <nl> public : <nl> / * * <nl> * @ js ctor <nl> class DataReaderHelper : cocos2d : : Object <nl> <nl> void addDataAsyncCallBack ( float dt ) ; <nl> <nl> + void removeConfigFile ( const char * configFile ) ; <nl> public : <nl> <nl> / * * <nl> class DataReaderHelper : cocos2d : : Object <nl> std : : queue < AsyncStruct * > * _asyncStructQueue ; <nl> std : : queue < DataInfo * > * _dataQueue ; <nl> <nl> + static std : : string _basefilePath ; <nl> + static std : : vector < std : : string > _configFileList ; <nl> <nl> static DataReaderHelper * _dataReaderHelper ; <nl> } ; <nl> mmm a / cocos / editor - support / cocostudio / CCTween . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCTween . cpp <nl> Tween : : Tween ( ) <nl> , _fromIndex ( 0 ) <nl> , _toIndex ( 0 ) <nl> , _animation ( NULL ) <nl> + , _passLastFrame ( false ) <nl> { <nl> <nl> } <nl> float Tween : : updateFrameData ( float currentPercent ) <nl> <nl> FrameData * from = NULL ; <nl> FrameData * to = NULL ; <nl> - bool passLastFrame = false ; <nl> <nl> if ( playedTime < frames [ 0 ] - > frameID ) <nl> { <nl> float Tween : : updateFrameData ( float currentPercent ) <nl> setBetween ( from , to ) ; <nl> return currentPercent ; <nl> } <nl> - else if ( playedTime > = frames [ length - 1 ] - > frameID ) <nl> + <nl> + if ( playedTime > = frames [ length - 1 ] - > frameID ) <nl> { <nl> - passLastFrame = true ; <nl> + / / If _passLastFrame is true and playedTime > = frames [ length - 1 ] - > frameID , then do not need to go on . <nl> + if ( _passLastFrame ) <nl> + { <nl> + return _currentPercent ; <nl> + } <nl> + _passLastFrame = true ; <nl> + } <nl> + else <nl> + { <nl> + _passLastFrame = false ; <nl> } <nl> <nl> <nl> float Tween : : updateFrameData ( float currentPercent ) <nl> _animation - > frameEvent ( _bone , from - > strEvent . c_str ( ) , from - > frameID , playedTime ) ; <nl> } <nl> <nl> - if ( playedTime = = from - > frameID | | ( passLastFrame & & _fromIndex = = length - 1 ) ) <nl> + if ( playedTime = = from - > frameID | | ( _passLastFrame & & _fromIndex = = length - 1 ) ) <nl> { <nl> break ; <nl> } <nl> mmm a / cocos / editor - support / cocostudio / CCTween . h <nl> ppp b / cocos / editor - support / cocostudio / CCTween . h <nl> class Tween : public ProcessBase <nl> / / ! A weak reference to the current MovementBoneData . The data is in the data pool <nl> CC_SYNTHESIZE ( MovementBoneData * , _movementBoneData , MovementBoneData ) <nl> <nl> - FrameData * _tweenData ; / / ! The computational tween frame data , / / ! A weak reference to the Bone ' s tweenData <nl> - FrameData * _from ; / / ! From frame data , used for calculate between value <nl> - FrameData * _to ; / / ! To frame data , used for calculate between value <nl> - FrameData * _between ; / / ! Between frame data , used for calculate current FrameData ( m_pNode ) value <nl> + FrameData * _tweenData ; / / ! The computational tween frame data , / / ! A weak reference to the Bone ' s tweenData <nl> + FrameData * _from ; / / ! From frame data , used for calculate between value <nl> + FrameData * _to ; / / ! To frame data , used for calculate between value <nl> + FrameData * _between ; / / ! Between frame data , used for calculate current FrameData ( m_pNode ) value <nl> <nl> <nl> - Bone * _bone ; / / ! A weak reference to the Bone <nl> + Bone * _bone ; / / ! A weak reference to the Bone <nl> <nl> - CCTweenType _frameTweenEasing ; / / ! Dedermine which tween effect current frame use <nl> + CCTweenType _frameTweenEasing ; / / ! Dedermine which tween effect current frame use <nl> <nl> - int _betweenDuration ; / / ! Current key frame will last _betweenDuration frames <nl> + int _betweenDuration ; / / ! Current key frame will last _betweenDuration frames <nl> int _totalDuration ; <nl> <nl> <nl> - int _fromIndex ; / / ! The current frame index in FrameList of MovementBoneData , it ' s different from m_iFrameIndex <nl> - int _toIndex ; / / ! The next frame index in FrameList of MovementBoneData , it ' s different from m_iFrameIndex <nl> + int _fromIndex ; / / ! The current frame index in FrameList of MovementBoneData , it ' s different from m_iFrameIndex <nl> + int _toIndex ; / / ! The next frame index in FrameList of MovementBoneData , it ' s different from m_iFrameIndex <nl> <nl> ArmatureAnimation * _animation ; <nl> <nl> + bool _passLastFrame ; / / ! If current frame index is more than the last frame ' s index <nl> } ; <nl> <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp <nl> Layer * CreateLayer ( int index ) <nl> case TEST_ASYNCHRONOUS_LOADING : <nl> pLayer = new TestAsynchronousLoading ( ) ; <nl> break ; <nl> + case TEST_DIRECT_LOADING : <nl> + pLayer = new TestDirectLoading ( ) ; <nl> + break ; <nl> case TEST_DRAGON_BONES_2_0 : <nl> pLayer = new TestDragonBones20 ( ) ; <nl> break ; <nl> Layer * CreateLayer ( int index ) <nl> case TEST_ANIMATION_EVENT : <nl> pLayer = new TestAnimationEvent ( ) ; <nl> break ; <nl> + case TEST_FRAME_EVENT : <nl> + pLayer = new TestFrameEvent ( ) ; <nl> + break ; <nl> case TEST_PARTICLE_DISPLAY : <nl> pLayer = new TestParticleDisplay ( ) ; <nl> break ; <nl> void TestAsynchronousLoading : : onEnter ( ) <nl> ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfoAsync ( " armature / hero . ExportJson " , this , schedule_selector ( TestAsynchronousLoading : : dataLoaded ) ) ; <nl> ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfoAsync ( " armature / horse . ExportJson " , this , schedule_selector ( TestAsynchronousLoading : : dataLoaded ) ) ; <nl> ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfoAsync ( " armature / bear . ExportJson " , this , schedule_selector ( TestAsynchronousLoading : : dataLoaded ) ) ; <nl> + ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfoAsync ( " armature / HeroAnimation . ExportJson " , this , schedule_selector ( TestAsynchronousLoading : : dataLoaded ) ) ; <nl> <nl> / / ! load data directly <nl> / / ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfo ( " armature / knight . png " , " armature / knight . plist " , " armature / knight . xml " ) ; <nl> std : : string TestAsynchronousLoading : : subtitle ( ) <nl> { <nl> return " current percent : " ; <nl> } <nl> + <nl> + void TestAsynchronousLoading : : restartCallback ( CCObject * pSender ) <nl> + { <nl> + ArmatureDataManager : : getInstance ( ) - > purge ( ) ; <nl> + ArmatureTestLayer : : restartCallback ( pSender ) ; <nl> + } <nl> void TestAsynchronousLoading : : dataLoaded ( float percent ) <nl> { <nl> LabelTTF * label = ( LabelTTF * ) getChildByTag ( 10001 ) ; <nl> void TestAsynchronousLoading : : dataLoaded ( float percent ) <nl> } <nl> <nl> <nl> + void TestDirectLoading : : onEnter ( ) <nl> + { <nl> + ArmatureTestLayer : : onEnter ( ) ; <nl> + <nl> + / / remove sigle resource <nl> + ArmatureDataManager : : getInstance ( ) - > removeArmatureFileInfo ( " armature / bear . ExportJson " ) ; <nl> + <nl> + / / load resource directly <nl> + ArmatureDataManager : : getInstance ( ) - > addArmatureFileInfo ( " armature / bear . ExportJson " ) ; <nl> + <nl> + Armature * armature = Armature : : create ( " bear " ) ; <nl> + armature - > getAnimation ( ) - > playByIndex ( 0 ) ; <nl> + armature - > setPosition ( ccp ( VisibleRect : : center ( ) . x , VisibleRect : : center ( ) . y ) ) ; <nl> + addChild ( armature ) ; <nl> + } <nl> + std : : string TestDirectLoading : : title ( ) <nl> + { <nl> + return " Test Direct Loading " ; <nl> + } <nl> + <nl> <nl> void TestCSWithSkeleton : : onEnter ( ) <nl> { <nl> void TestAnimationEvent : : callback2 ( ) <nl> <nl> <nl> <nl> + # define FRAME_EVENT_ACTION_TAG 10000 <nl> + <nl> + void TestFrameEvent : : onEnter ( ) <nl> + { <nl> + ArmatureTestLayer : : onEnter ( ) ; <nl> + Armature * armature = Armature : : create ( " HeroAnimation " ) ; <nl> + armature - > getAnimation ( ) - > play ( " attack " ) ; <nl> + armature - > getAnimation ( ) - > setSpeedScale ( 0 . 5 ) ; <nl> + armature - > setPosition ( Point ( VisibleRect : : center ( ) . x - 50 , VisibleRect : : center ( ) . y - 100 ) ) ; <nl> + <nl> + / * <nl> + * Set armature ' s frame event callback function <nl> + * To disconnect this event , just setFrameEventCallFunc ( NULL , NULL ) ; <nl> + * / <nl> + armature - > getAnimation ( ) - > setFrameEventCallFunc ( this , frameEvent_selector ( TestFrameEvent : : onFrameEvent ) ) ; <nl> + <nl> + addChild ( armature ) ; <nl> + <nl> + schedule ( schedule_selector ( TestFrameEvent : : checkAction ) ) ; <nl> + } <nl> + std : : string TestFrameEvent : : title ( ) <nl> + { <nl> + return " Test Frame Event " ; <nl> + } <nl> + void TestFrameEvent : : onFrameEvent ( Bone * bone , const char * evt , int originFrameIndex , int currentFrameIndex ) <nl> + { <nl> + CCLOG ( " ( % s ) emit a frame event ( % s ) at frame index ( % d ) . " , bone - > getName ( ) . c_str ( ) , evt , currentFrameIndex ) ; <nl> + <nl> + <nl> + if ( ! this - > getActionByTag ( FRAME_EVENT_ACTION_TAG ) | | this - > getActionByTag ( FRAME_EVENT_ACTION_TAG ) - > isDone ( ) ) <nl> + { <nl> + this - > stopAllActions ( ) ; <nl> + <nl> + ActionInterval * action = ShatteredTiles3D : : create ( 0 . 2f , Size ( 16 , 12 ) , 5 , false ) ; <nl> + action - > setTag ( FRAME_EVENT_ACTION_TAG ) ; <nl> + this - > runAction ( action ) ; <nl> + } <nl> + } <nl> + void TestFrameEvent : : checkAction ( float dt ) <nl> + { <nl> + if ( this - > numberOfRunningActions ( ) = = 0 & & this - > getGrid ( ) ! = NULL ) <nl> + this - > setGrid ( NULL ) ; <nl> + } <nl> + <nl> + <nl> <nl> void TestParticleDisplay : : onEnter ( ) <nl> { <nl> void TestColliderDetector : : initWorld ( ) <nl> <nl> bullet - > setCPBody ( body ) ; <nl> <nl> - body = cpBodyNew ( INFINITY , INFINITY ) ; <nl> + body = cpBodyNew ( 1 . 0f , INFINITY ) ; <nl> cpSpaceAddBody ( space , body ) ; <nl> armature2 - > setBody ( body ) ; <nl> <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . h <nl> class ArmatureTestScene : public TestScene <nl> <nl> enum { <nl> TEST_ASYNCHRONOUS_LOADING = 0 , <nl> + TEST_DIRECT_LOADING , <nl> TEST_COCOSTUDIO_WITH_SKELETON , <nl> TEST_DRAGON_BONES_2_0 , <nl> TEST_PERFORMANCE , <nl> TEST_PERFORMANCE_BATCHNODE , <nl> TEST_CHANGE_ZORDER , <nl> TEST_ANIMATION_EVENT , <nl> + TEST_FRAME_EVENT , <nl> TEST_PARTICLE_DISPLAY , <nl> TEST_USE_DIFFERENT_PICTURE , <nl> TEST_BCOLLIDER_DETECTOR , <nl> class TestAsynchronousLoading : public ArmatureTestLayer <nl> virtual void onEnter ( ) ; <nl> virtual std : : string title ( ) ; <nl> virtual std : : string subtitle ( ) ; <nl> + virtual void restartCallback ( CCObject * pSender ) ; <nl> <nl> void dataLoaded ( float percent ) ; <nl> } ; <nl> <nl> + class TestDirectLoading : public ArmatureTestLayer <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + virtual std : : string title ( ) ; <nl> + } ; <nl> + <nl> class TestCSWithSkeleton : public ArmatureTestLayer <nl> { <nl> virtual void onEnter ( ) ; <nl> class TestAnimationEvent : public ArmatureTestLayer <nl> cocostudio : : Armature * armature ; <nl> } ; <nl> <nl> + <nl> + class TestFrameEvent : public ArmatureTestLayer <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + virtual std : : string title ( ) ; <nl> + void onFrameEvent ( cocostudio : : Bone * bone , const char * evt , int originFrameIndex , int currentFrameIndex ) ; <nl> + void checkAction ( float dt ) ; <nl> + } ; <nl> + <nl> + <nl> class TestUseMutiplePicture : public ArmatureTestLayer <nl> { <nl> virtual void onEnter ( ) ; <nl> | 1 . fix if frame event is at the last frame , it may emit event several times | cocos2d/cocos2d-x | 005d3c012103ddb31a2867251ae24276695825c4 | 2013-10-31T09:28:14Z |
mmm a / cocos / 2d / ccConfig . h <nl> ppp b / cocos / 2d / ccConfig . h <nl> To enable set it to a value different than 0 . Disabled by default . <nl> <nl> # ifdef CC_USE_PHYSICS <nl> # define PHYSICS_CONTACT_POINT_MAX 4 <nl> - namespace cocos2d <nl> - { <nl> - class Point ; <nl> - typedef Point Vect ; <nl> - } <nl> # endif <nl> <nl> # endif / / __CCCONFIG_H__ <nl> mmm a / cocos / physics / CCPhysicsBody . h <nl> ppp b / cocos / physics / CCPhysicsBody . h <nl> NS_CC_BEGIN <nl> class Sprite ; <nl> class PhysicsWorld ; <nl> class PhysicsJoint ; <nl> - <nl> class PhysicsBodyInfo ; <nl> <nl> + typedef Point Vect ; <nl> + <nl> <nl> const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT ( 0 . 1f , 0 . 5f , 0 . 5f ) ; <nl> <nl> mmm a / cocos / physics / CCPhysicsContact . h <nl> ppp b / cocos / physics / CCPhysicsContact . h <nl> class PhysicsWorld ; <nl> <nl> class PhysicsContactInfo ; <nl> <nl> + typedef Point Vect ; <nl> <nl> typedef struct PhysicsContactData <nl> { <nl> mmm a / cocos / physics / CCPhysicsWorld . h <nl> ppp b / cocos / physics / CCPhysicsWorld . h <nl> class PhysicsShape ; <nl> class PhysicsContact ; <nl> class Array ; <nl> <nl> + typedef Point Vect ; <nl> + <nl> class Sprite ; <nl> class Scene ; <nl> class DrawNode ; <nl> mmm a / cocos / physics / chipmunk / CCPhysicsWorldInfo_chipmunk . h <nl> ppp b / cocos / physics / chipmunk / CCPhysicsWorldInfo_chipmunk . h <nl> <nl> # include " CCPlatformMacros . h " <nl> # include " CCGeometry . h " <nl> NS_CC_BEGIN <nl> - class Vect ; <nl> + typedef Point Vect ; <nl> class PhysicsBodyInfo ; <nl> class PhysicsJointInfo ; <nl> class PhysicsShapeInfo ; <nl> | issue : fix compile errors | cocos2d/cocos2d-x | 0100c05a933f9b0280ebb2a54f8ece45acb1a108 | 2013-11-26T09:29:09Z |
mmm a / modules / java / generator / src / java / android + CameraBridgeViewBase . java <nl> ppp b / modules / java / generator / src / java / android + CameraBridgeViewBase . java <nl> <nl> import org . opencv . android . Utils ; <nl> import org . opencv . core . Mat ; <nl> import org . opencv . core . Size ; <nl> - import org . opencv . highgui . Highgui ; <nl> <nl> import android . app . Activity ; <nl> import android . app . AlertDialog ; <nl> <nl> protected int mFrameHeight ; <nl> protected int mMaxHeight ; <nl> protected int mMaxWidth ; <nl> - protected int mPreviewFormat = Highgui . CV_CAP_ANDROID_COLOR_FRAME_RGBA ; <nl> protected int mCameraIndex = - 1 ; <nl> protected boolean mEnabled ; <nl> protected FpsMeter mFpsMeter = null ; <nl> public CameraBridgeViewBase ( Context context , AttributeSet attrs ) { <nl> * The returned values - is a modified frame which needs to be displayed on the screen . <nl> * TODO : pass the parameters specifying the format of the frame ( BPP , YUV or RGB and etc ) <nl> * / <nl> - public Mat onCameraFrame ( Mat inputFrame ) ; <nl> + public Mat onCameraFrame ( CvCameraViewFrame inputFrame ) ; <nl> <nl> } <nl> <nl> + public interface CvCameraViewFrame { <nl> + public abstract Mat rgba ( ) ; <nl> + public abstract Mat gray ( ) ; <nl> + } ; <nl> + <nl> public void surfaceChanged ( SurfaceHolder arg0 , int arg1 , int arg2 , int arg3 ) { <nl> Log . d ( TAG , " call surfaceChanged event " ) ; <nl> synchronized ( mSyncObject ) { <nl> public void setMaxFrameSize ( int maxWidth , int maxHeight ) { <nl> mMaxHeight = maxHeight ; <nl> } <nl> <nl> - public void SetCaptureFormat ( int format ) <nl> - { <nl> - mPreviewFormat = format ; <nl> - } <nl> - <nl> / * * <nl> * Called when mSyncObject lock is held <nl> * / <nl> private void onExitStartedState ( ) { <nl> * then displayed on the screen . <nl> * @ param frame - the current frame to be delivered <nl> * / <nl> - protected void deliverAndDrawFrame ( Mat frame ) { <nl> + protected void deliverAndDrawFrame ( CvCameraViewFrame frame ) { <nl> Mat modified ; <nl> <nl> if ( mListener ! = null ) { <nl> modified = mListener . onCameraFrame ( frame ) ; <nl> } else { <nl> - modified = frame ; <nl> + modified = frame . rgba ( ) ; <nl> } <nl> <nl> boolean bmpValid = true ; <nl> mmm a / modules / java / generator / src / java / android + JavaCameraView . java <nl> ppp b / modules / java / generator / src / java / android + JavaCameraView . java <nl> <nl> import org . opencv . core . CvType ; <nl> import org . opencv . core . Mat ; <nl> import org . opencv . core . Size ; <nl> - import org . opencv . highgui . Highgui ; <nl> import org . opencv . imgproc . Imgproc ; <nl> <nl> / * * <nl> <nl> private static final int MAGIC_TEXTURE_ID = 10 ; <nl> private static final String TAG = " JavaCameraView " ; <nl> <nl> - private Mat mBaseMat ; <nl> private byte mBuffer [ ] ; <nl> private Mat [ ] mFrameChain ; <nl> private int mChainIdx = 0 ; <nl> <nl> private boolean mStopThread ; <nl> <nl> protected Camera mCamera ; <nl> - <nl> + protected JavaCameraFrame mCameraFrame ; <nl> private SurfaceTexture mSurfaceTexture ; <nl> <nl> public static class JavaCameraSizeAccessor implements ListItemAccessor { <nl> protected boolean initializeCamera ( int width , int height ) { <nl> mCamera . addCallbackBuffer ( mBuffer ) ; <nl> mCamera . setPreviewCallbackWithBuffer ( this ) ; <nl> <nl> - mBaseMat = new Mat ( mFrameHeight + ( mFrameHeight / 2 ) , mFrameWidth , CvType . CV_8UC1 ) ; <nl> - <nl> mFrameChain = new Mat [ 2 ] ; <nl> - mFrameChain [ 0 ] = new Mat ( ) ; <nl> - mFrameChain [ 1 ] = new Mat ( ) ; <nl> + mFrameChain [ 0 ] = new Mat ( mFrameHeight + ( mFrameHeight / 2 ) , mFrameWidth , CvType . CV_8UC1 ) ; <nl> + mFrameChain [ 1 ] = new Mat ( mFrameHeight + ( mFrameHeight / 2 ) , mFrameWidth , CvType . CV_8UC1 ) ; <nl> <nl> AllocateCache ( ) ; <nl> <nl> + mCameraFrame = new JavaCameraFrame ( mFrameChain [ mChainIdx ] , mFrameWidth , mFrameHeight ) ; <nl> + <nl> if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . HONEYCOMB ) { <nl> mSurfaceTexture = new SurfaceTexture ( MAGIC_TEXTURE_ID ) ; <nl> getHolder ( ) . setType ( SurfaceHolder . SURFACE_TYPE_PUSH_BUFFERS ) ; <nl> protected void releaseCamera ( ) { <nl> mCamera . release ( ) ; <nl> } <nl> mCamera = null ; <nl> - if ( mBaseMat ! = null ) <nl> - mBaseMat . release ( ) ; <nl> if ( mFrameChain ! = null ) { <nl> mFrameChain [ 0 ] . release ( ) ; <nl> mFrameChain [ 1 ] . release ( ) ; <nl> } <nl> + if ( mCameraFrame ! = null ) <nl> + mCameraFrame . release ( ) ; <nl> } <nl> } <nl> <nl> public void onPreviewFrame ( byte [ ] frame , Camera arg1 ) { <nl> Log . i ( TAG , " Frame size is " + frame . length ) ; <nl> synchronized ( this ) <nl> { <nl> - mBaseMat . put ( 0 , 0 , frame ) ; <nl> + mFrameChain [ 1 - mChainIdx ] . put ( 0 , 0 , frame ) ; <nl> this . notify ( ) ; <nl> } <nl> if ( mCamera ! = null ) <nl> mCamera . addCallbackBuffer ( mBuffer ) ; <nl> } <nl> <nl> + private class JavaCameraFrame implements CvCameraViewFrame <nl> + { <nl> + public Mat gray ( ) { <nl> + return mYuvFrameData . submat ( 0 , mHeight , 0 , mWidth ) ; <nl> + } <nl> + <nl> + public Mat rgba ( ) { <nl> + Imgproc . cvtColor ( mYuvFrameData , mRgba , Imgproc . COLOR_YUV2BGR_NV12 , 4 ) ; <nl> + return mRgba ; <nl> + } <nl> + <nl> + public JavaCameraFrame ( Mat Yuv420sp , int width , int height ) { <nl> + super ( ) ; <nl> + mWidth = width ; <nl> + mHeight = height ; <nl> + mYuvFrameData = Yuv420sp ; <nl> + mRgba = new Mat ( mHeight , mWidth , CvType . CV_8UC4 ) ; <nl> + } <nl> + <nl> + public void release ( ) { <nl> + mRgba . release ( ) ; <nl> + } <nl> + <nl> + private JavaCameraFrame ( CvCameraViewFrame obj ) { <nl> + } <nl> + <nl> + private Mat mYuvFrameData ; <nl> + private Mat mRgba ; <nl> + private int mWidth ; <nl> + private int mHeight ; <nl> + } ; <nl> + <nl> private class CameraWorker implements Runnable { <nl> <nl> public void run ( ) { <nl> public void run ( ) { <nl> } <nl> <nl> if ( ! mStopThread ) { <nl> - switch ( mPreviewFormat ) { <nl> - case Highgui . CV_CAP_ANDROID_COLOR_FRAME_RGBA : <nl> - Imgproc . cvtColor ( mBaseMat , mFrameChain [ mChainIdx ] , Imgproc . COLOR_YUV2RGBA_NV21 , 4 ) ; <nl> - break ; <nl> - case Highgui . CV_CAP_ANDROID_GREY_FRAME : <nl> - mFrameChain [ mChainIdx ] = mBaseMat . submat ( 0 , mFrameHeight , 0 , mFrameWidth ) ; <nl> - break ; <nl> - default : <nl> - Log . e ( TAG , " Invalid frame format ! Only RGBA and Gray Scale are supported ! " ) ; <nl> - } ; <nl> if ( ! mFrameChain [ mChainIdx ] . empty ( ) ) <nl> - deliverAndDrawFrame ( mFrameChain [ mChainIdx ] ) ; <nl> + deliverAndDrawFrame ( mCameraFrame ) ; <nl> mChainIdx = 1 - mChainIdx ; <nl> } <nl> } while ( ! mStopThread ) ; <nl> mmm a / modules / java / generator / src / java / android + NativeCameraView . java <nl> ppp b / modules / java / generator / src / java / android + NativeCameraView . java <nl> private void releaseCamera ( ) { <nl> } <nl> } <nl> <nl> + private class NativeCameraFrame implements CvCameraViewFrame { <nl> + <nl> + @ Override <nl> + public Mat rgba ( ) { <nl> + mCamera . retrieve ( mRgba , Highgui . CV_CAP_ANDROID_COLOR_FRAME_RGBA ) ; <nl> + return mRgba ; <nl> + } <nl> + <nl> + @ Override <nl> + public Mat gray ( ) { <nl> + mCamera . retrieve ( mGray , Highgui . CV_CAP_ANDROID_GREY_FRAME ) ; <nl> + return mGray ; <nl> + } <nl> + <nl> + public NativeCameraFrame ( VideoCapture capture ) { <nl> + mCapture = capture ; <nl> + mGray = new Mat ( ) ; <nl> + mRgba = new Mat ( ) ; <nl> + } <nl> + <nl> + private VideoCapture mCapture ; <nl> + private Mat mRgba ; <nl> + private Mat mGray ; <nl> + } ; <nl> + <nl> private class CameraWorker implements Runnable { <nl> <nl> private Mat mRgba = new Mat ( ) ; <nl> public void run ( ) { <nl> break ; <nl> } <nl> <nl> - switch ( mPreviewFormat ) { <nl> - case Highgui . CV_CAP_ANDROID_COLOR_FRAME_RGBA : <nl> - { <nl> - mCamera . retrieve ( mRgba , Highgui . CV_CAP_ANDROID_COLOR_FRAME_RGBA ) ; <nl> - deliverAndDrawFrame ( mRgba ) ; <nl> - } break ; <nl> - case Highgui . CV_CAP_ANDROID_GREY_FRAME : <nl> - mCamera . retrieve ( mGray , Highgui . CV_CAP_ANDROID_GREY_FRAME ) ; <nl> - deliverAndDrawFrame ( mGray ) ; <nl> - break ; <nl> - default : <nl> - Log . e ( TAG , " Invalid frame format ! Only RGBA and Gray Scale are supported ! " ) ; <nl> - } <nl> + deliverAndDrawFrame ( new NativeCameraFrame ( mCamera ) ) ; <nl> <nl> } while ( ! mStopThread ) ; <nl> - <nl> } <nl> } <nl> <nl> | onCameraFrame callback signature changed . CvCameraFame interface added . | opencv/opencv | 3ef588b877664679d0e28dea81937294a193a5a0 | 2013-02-04T13:43:45Z |
mmm a / modules / detectron / upsample_nearest_op . h <nl> ppp b / modules / detectron / upsample_nearest_op . h <nl> class UpsampleNearestOp final : public Operator < Context > { <nl> bool RunOnDevice ( ) override { <nl> auto & X = Input ( 0 ) ; <nl> auto * Y = Output ( 0 ) ; <nl> - auto out_shape = X . dims ( ) . vec ( ) ; <nl> + auto out_shape = X . sizes ( ) . vec ( ) ; <nl> out_shape [ X . ndim ( ) - 1 ] * = scale_ ; <nl> out_shape [ X . ndim ( ) - 2 ] * = scale_ ; <nl> Y - > Resize ( out_shape ) ; <nl> | Renaming dims ( ) to sizes ( ) ( fbcode ) | pytorch/pytorch | e5752f2cb4cf86db370d6d9cb3d6158f04d3251c | 2018-10-25T16:32:18Z |
mmm a / tests / lua - tests / src / controller . lua <nl> ppp b / tests / lua - tests / src / controller . lua <nl> collectgarbage ( " setstepmul " , 5000 ) <nl> local director = cc . Director : getInstance ( ) <nl> local glView = director : getOpenGLView ( ) <nl> if nil = = glView then <nl> - glView = cc . GLView : createWithRect ( " Lua Tests " , cc . Rect ( 0 , 0 , 900 , 640 ) ) <nl> + glView = cc . GLView : createWithRect ( " Lua Tests " , cc . rect ( 0 , 0 , 900 , 640 ) ) <nl> + director : setOpenGLView ( glView ) <nl> end <nl> <nl> - - turn on display FPS <nl> | Fix the tests - lua crash on windows platform | cocos2d/cocos2d-x | 9c7999d1c23c82e0bc8a737f59770096473d177c | 2014-07-11T10:13:08Z |
mmm a / src / settings_internal . js <nl> ppp b / src / settings_internal . js <nl> var PROXIED_FUNCTION_SIGNATURES = [ ] ; <nl> / / List of function explicitly exported by user on the command line . <nl> var USER_EXPORTED_FUNCTIONS = [ ] ; <nl> <nl> - / / name of the file containing wasm text , if relevant <nl> - var WASM_TEXT_FILE = ' ' ; <nl> - <nl> / / name of the file containing wasm binary , if relevant <nl> var WASM_BINARY_FILE = ' ' ; <nl> <nl> mmm a / tools / shared . py <nl> ppp b / tools / shared . py <nl> def reconfigure_cache ( ) : <nl> <nl> # Placeholder strings used for SINGLE_FILE <nl> class FilenameReplacementStrings : <nl> - WASM_TEXT_FILE = ' { { { FILENAME_REPLACEMENT_STRINGS_WASM_TEXT_FILE } } } ' <nl> WASM_BINARY_FILE = ' { { { FILENAME_REPLACEMENT_STRINGS_WASM_BINARY_FILE } } } ' <nl> <nl> <nl> | Remove unused WASM_TEXT_FILE . NFC . ( ) | emscripten-core/emscripten | 751eed6a5f01c9607e0d229f12308c6a1d3c7239 | 2020-10-12T21:04:24Z |
mmm a / build / fbcode_builder / getdeps . py <nl> ppp b / build / fbcode_builder / getdeps . py <nl> def run ( self , args ) : <nl> class ProjectCmdBase ( SubCmd ) : <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> + <nl> + if args . current_project is not None : <nl> + opts . repo_project = args . current_project <nl> + if args . project is None : <nl> + if opts . repo_project is None : <nl> + raise UsageError ( <nl> + " no project name specified , and no . projectid file found " <nl> + ) <nl> + if opts . repo_project = = " fbsource " : <nl> + # The fbsource repository is a little special . There is no project <nl> + # manifest file for it . A specific project must always be explicitly <nl> + # specified when building from fbsource . <nl> + raise UsageError ( <nl> + " no project name specified ( required when building in fbsource ) " <nl> + ) <nl> + args . project = opts . repo_project <nl> + <nl> ctx_gen = opts . get_context_generator ( facebook_internal = args . facebook_internal ) <nl> if args . test_dependencies : <nl> ctx_gen . set_value_for_all_projects ( " test " , " on " ) <nl> def parse_project_arg ( arg , arg_type ) : <nl> <nl> return project , os . path . abspath ( path ) <nl> <nl> + # If we are currently running from a project repository , <nl> + # use the current repository for the project sources . <nl> + build_opts = loader . build_opts <nl> + if build_opts . repo_project is not None and build_opts . repo_root is not None : <nl> + loader . set_project_src_dir ( build_opts . repo_project , build_opts . repo_root ) <nl> + <nl> for arg in args . src_dir : <nl> project , path = parse_project_arg ( arg , " - - src - dir " ) <nl> loader . set_project_src_dir ( project , path ) <nl> def parse_project_arg ( arg , arg_type ) : <nl> def setup_parser ( self , parser ) : <nl> parser . add_argument ( <nl> " project " , <nl> + nargs = " ? " , <nl> help = ( <nl> " name of the project or path to a manifest " <nl> " file describing the project " <nl> def setup_parser ( self , parser ) : <nl> action = " store_true " , <nl> help = " Enable building tests for dependencies as well . " , <nl> ) <nl> + parser . add_argument ( <nl> + " - - current - project " , <nl> + help = " Specify the name of the fbcode_builder manifest file for the " <nl> + " current repository . If not specified , the code will attempt to find " <nl> + " this in a . projectid file in the repository root . " , <nl> + ) <nl> parser . add_argument ( <nl> " - - src - dir " , <nl> default = [ ] , <nl> mmm a / build / fbcode_builder / getdeps / buildopts . py <nl> ppp b / build / fbcode_builder / getdeps / buildopts . py <nl> def containing_repo_type ( path ) : <nl> <nl> parent = os . path . dirname ( path ) <nl> if parent = = path : <nl> - return None <nl> + return None , None <nl> path = parent <nl> <nl> <nl> + def detect_project ( path ) : <nl> + repo_type , repo_root = containing_repo_type ( path ) <nl> + if repo_type is None : <nl> + return None , None <nl> + <nl> + # Look for a . projectid file . If it exists , read the project name from it . <nl> + project_id_path = os . path . join ( repo_root , " . projectid " ) <nl> + try : <nl> + with open ( project_id_path , " r " ) as f : <nl> + project_name = f . read ( ) . strip ( ) <nl> + return repo_root , project_name <nl> + except EnvironmentError as ex : <nl> + if ex . errno ! = errno . ENOENT : <nl> + raise <nl> + <nl> + return repo_root , None <nl> + <nl> + <nl> class BuildOptions ( object ) : <nl> def __init__ ( <nl> self , <nl> def __init__ ( <nl> self . project_hashes = hashes <nl> break <nl> <nl> - # Use a simplistic heuristic to figure out if we ' re in fbsource <nl> - # and where the root of fbsource can be found <nl> - repo_type , repo_root = containing_repo_type ( fbcode_builder_dir ) <nl> - if repo_type = = " hg " : <nl> - self . fbsource_dir = repo_root <nl> + # Detect what repository and project we are being run from . <nl> + self . repo_root , self . repo_project = detect_project ( os . getcwd ( ) ) <nl> + <nl> + # If we are running from an fbsource repository , set self . fbsource_dir <nl> + # to allow the ShipIt - based fetchers to use it . <nl> + if self . repo_project = = " fbsource " : <nl> + self . fbsource_dir = self . repo_root <nl> else : <nl> self . fbsource_dir = None <nl> <nl> | fbcode_builder : implement automatic project detection from the current repo | facebook/watchman | c91fabea702b6d133b748194c519770b76d6fb97 | 2019-09-20T21:14:39Z |
mmm a / xbmc / utils / LangCodeExpander . cpp <nl> ppp b / xbmc / utils / LangCodeExpander . cpp <nl> const CharCodeConvertionWithHack CharCode2To3 [ 189 ] = <nl> { " br " , " bre " , NULL } , <nl> { " bg " , " bul " , NULL } , <nl> { " ca " , " cat " , NULL } , <nl> - { " cs " , " cze " , " csy " } , <nl> + { " cs " , " cze " , " ces " } , <nl> { " ch " , " cha " , NULL } , <nl> { " ce " , " che " , NULL } , <nl> { " cu " , " chu " , NULL } , <nl> const CharCodeConvertionWithHack CharCode2To3 [ 189 ] = <nl> { " yi " , " yid " , NULL } , <nl> { " yo " , " yor " , NULL } , <nl> { " za " , " zha " , NULL } , <nl> - { " zh " , " chi " , NULL } , <nl> + { " zh " , " chi " , " zho " } , <nl> { " zu " , " zul " , NULL } , <nl> { " zv " , " und " , NULL } , / / XBMC intern mapping for missing " Undetermined " iso639 - 1 code <nl> { " zx " , " zxx " , NULL } , / / XBMC intern mapping for missing " No linguistic content " iso639 - 1 code <nl> | Merge pull request from ace20022 / ces_zho | xbmc/xbmc | b2c3e3a15fef15f5e57d7edc67ea324264518e69 | 2014-09-20T10:36:21Z |
mmm a / osquery / devtools / shell . cpp <nl> ppp b / osquery / devtools / shell . cpp <nl> static void output_csv ( struct callback_data * p , const char * z , int bSep ) { <nl> / * <nl> * * This routine runs when the user presses Ctrl - C <nl> * / <nl> - static void interrupt_handler ( int NotUsed ) { <nl> - UNUSED_PARAMETER ( NotUsed ) ; <nl> + static void interrupt_handler ( int signal ) { <nl> + if ( signal = = SIGINT ) { <nl> + osquery : : shutdown ( 130 ) ; <nl> + } <nl> seenInterrupt = 1 ; <nl> } <nl> # endif <nl> static sqlite3_int64 integerValue ( const char * zArg ) { <nl> char * zSuffix ; <nl> int iMult ; <nl> } aMult [ ] = { <nl> - { ( char * ) " KiB " , 1024 } , <nl> - { ( char * ) " MiB " , 1024 * 1024 } , <nl> - { ( char * ) " GiB " , 1024 * 1024 * 1024 } , <nl> - { ( char * ) " KB " , 1000 } , <nl> - { ( char * ) " MB " , 1000000 } , <nl> - { ( char * ) " GB " , 1000000000 } , <nl> - { ( char * ) " K " , 1000 } , <nl> - { ( char * ) " M " , 1000000 } , <nl> - { ( char * ) " G " , 1000000000 } , <nl> - } ; <nl> + { ( char * ) " KiB " , 1024 } , <nl> + { ( char * ) " MiB " , 1024 * 1024 } , <nl> + { ( char * ) " GiB " , 1024 * 1024 * 1024 } , <nl> + { ( char * ) " KB " , 1000 } , <nl> + { ( char * ) " MB " , 1000000 } , <nl> + { ( char * ) " GB " , 1000000000 } , <nl> + { ( char * ) " K " , 1000 } , <nl> + { ( char * ) " M " , 1000000 } , <nl> + { ( char * ) " G " , 1000000000 } , <nl> + } ; <nl> int i ; <nl> int isNeg = 0 ; <nl> if ( zArg [ 0 ] = = ' - ' ) { <nl> | Merge pull request from theopolis / end_shell | osquery/osquery | 1bd518ec092baa31d09b22a59f604de676215319 | 2016-02-12T06:29:04Z |
mmm a / src / objective - c / examples / Sample / SampleTests / RemoteProtoTests . m <nl> ppp b / src / objective - c / examples / Sample / SampleTests / RemoteProtoTests . m <nl> - ( void ) testCancelAfterBeginRPC { <nl> [ self waitForExpectationsWithTimeout : 1 handler : nil ] ; <nl> } <nl> <nl> + - ( void ) testCancelAfterFirstResponseRPC { <nl> + __weak XCTestExpectation * expectation = [ self expectationWithDescription : @ " CancelAfterFirstResponse " ] ; <nl> + <nl> + / / A buffered pipe to which we never write any value acts as a writer that just hangs . <nl> + GRXBufferedPipe * requestsBuffer = [ [ GRXBufferedPipe alloc ] init ] ; <nl> + <nl> + __block bool receivedResponse = false ; <nl> + <nl> + id request = [ RMTStreamingOutputCallRequest messageWithPayloadSize : @ 21782 <nl> + requestedResponseSize : @ 31415 ] ; <nl> + <nl> + [ requestsBuffer writeValue : request ] ; <nl> + <nl> + __block ProtoRPC * call = [ _service RPCToFullDuplexCallWithRequestsWriter : requestsBuffer <nl> + handler : ^ ( BOOL done , <nl> + RMTStreamingOutputCallResponse * response , <nl> + NSError * error ) { <nl> + if ( receivedResponse ) { <nl> + XCTAssert ( done , @ " Unexpected extra response % @ " , response ) ; <nl> + XCTAssertEqual ( error . code , GRPC_STATUS_CANCELLED ) ; <nl> + [ expectation fulfill ] ; <nl> + } else { <nl> + XCTAssertNil ( error , @ " Finished with unexpected error : % @ " , error ) ; <nl> + XCTAssertFalse ( done , @ " Finished without response " ) ; <nl> + XCTAssertNotNil ( response ) ; <nl> + receivedResponse = true ; <nl> + [ call cancel ] ; <nl> + } <nl> + } ] ; <nl> + [ call start ] ; <nl> + [ self waitForExpectationsWithTimeout : 4 handler : nil ] ; <nl> + } <nl> + <nl> @ end <nl> | Added cancel_after_first_response test | grpc/grpc | dbfe2f437c532548ac3d4ecc21737fd6419a217f | 2015-05-20T18:59:20Z |
mmm a / src / parseTools . js <nl> ppp b / src / parseTools . js <nl> function makeSetValue ( ptr , pos , value , type , noNeedFirst , ignore , align , noSafe , <nl> value = range ( typeData . fields . length ) . map ( function ( i ) { return value + ' . f ' + i } ) ; <nl> } <nl> for ( var i = 0 ; i < typeData . fields . length ; i + + ) { <nl> - ret . push ( makeSetValue ( ptr , pos + typeData . flatIndexes [ i ] , value [ i ] , typeData . fields [ i ] , noNeedFirst ) ) ; <nl> + ret . push ( makeSetValue ( ptr , getFastValue ( pos , ' + ' , typeData . flatIndexes [ i ] ) , value [ i ] , typeData . fields [ i ] , noNeedFirst ) ) ; <nl> } <nl> return ret . join ( ' ; ' ) ; <nl> } <nl> mmm a / tests / cases / complexphi . ll <nl> ppp b / tests / cases / complexphi . ll <nl> target datalayout = " e - p : 32 : 32 : 32 - i1 : 8 : 8 - i8 : 8 : 8 - i16 : 16 : 16 - i32 : 32 : 32 - i64 : 32 : 64 - f3 <nl> target triple = " i386 - pc - linux - gnu " <nl> <nl> @ . str = private unnamed_addr constant [ 15 x i8 ] c " hello , world ! \ 0A \ 00 " , align 1 ; [ # uses = 1 type = [ 15 x i8 ] * ] <nl> + @ _dispatchTable = internal global i64 0 <nl> <nl> ; [ # uses = 0 ] <nl> define i32 @ main ( ) { <nl> cond . null : <nl> cond . end : ; preds = % cond . false , % cond . true <nl> % cond = phi { i32 , i32 } [ { i32 5 , i32 6 } , % entry ] , [ zeroinitializer , % cond . null ] ; [ # uses = 1 ] <nl> store { i32 , i32 } % cond , { i32 , i32 } * % comp <nl> + <nl> + store { i32 , i32 } { i32 ptrtoint ( i64 * @ _dispatchTable to i32 ) , i32 0 } , { i32 , i32 } * getelementptr inbounds ( [ 1 x i64 ] * @ _dispatchTable , i32 0 , i32 0 , i32 1 ) , align 4 <nl> + <nl> ret i32 0 ; [ debug line = 6 : 13 ] <nl> } <nl> <nl> | fix makeSetValue on complex structural types , fixes | emscripten-core/emscripten | 953323e80a9765fc3d7d7bfd3134d1a4a9c48580 | 2012-04-15T03:51:13Z |
mmm a / modules / bridge / udp_bridge_component . cc <nl> ppp b / modules / bridge / udp_bridge_component . cc <nl> namespace bridge { <nl> # define BRIDGE_IMPL ( pb_msg ) \ <nl> template class UDPBridgeComponent < pb_msg > <nl> <nl> - # define _1K 1024 <nl> + # define _1K 1024 <nl> <nl> using apollo : : cyber : : io : : Session ; <nl> using apollo : : localization : : LocalizationEstimate ; <nl> | bridge : fromat code style | ApolloAuto/apollo | e2e4d68b83a20cad5d5ab09868d484de8759a1ff | 2019-05-20T21:14:00Z |
mmm a / build / fbcode_builder / getdeps / builder . py <nl> ppp b / build / fbcode_builder / getdeps / builder . py <nl> def _resolve_dep_to_git ( self ) : <nl> dep_to_git = { } <nl> for dep in dependencies . keys ( ) : <nl> dep_manifest = self . loader . load_manifest ( dep ) <nl> - if dep_manifest . get ( " build " , " builder " , ctx = self . ctx ) ! = " cargo " : <nl> + dep_builder = dep_manifest . get ( " build " , " builder " , ctx = self . ctx ) <nl> + if dep_builder not in [ " cargo " , " nop " ] or dep = = " rust " : <nl> # This is a direct dependency , but it is not build with cargo <nl> - # so ignore it . <nl> + # and it is not simply copying files with nop , so ignore it . <nl> + # The " rust " dependency is an exception since it contains the <nl> + # toolchain . <nl> continue <nl> <nl> git_conf = dep_manifest . get_section_as_dict ( " git " , ctx = self . ctx ) <nl> def _resolve_dep_to_git ( self ) : <nl> raise Exception ( <nl> " A cargo dependency requires git . repo_url to be defined . " <nl> ) <nl> - git_conf [ " inst_dir " ] = self . loader . get_project_install_dir ( dep_manifest ) <nl> + source_dir = self . loader . get_project_install_dir ( dep_manifest ) <nl> + if dep_builder = = " cargo " : <nl> + source_dir = os . path . join ( source_dir , " source " ) <nl> + git_conf [ " source_dir " ] = source_dir <nl> dep_to_git [ dep ] = git_conf <nl> return dep_to_git <nl> <nl> def _resolve_crate_to_path ( crate , git_conf ) : <nl> Tries to find < crate > in git_conf [ " inst_dir " ] by searching a [ package ] <nl> keyword followed by name = " < crate > " . <nl> " " " <nl> - source_dir = os . path . join ( git_conf [ " inst_dir " ] , " source " ) <nl> + source_dir = git_conf [ " source_dir " ] <nl> search_pattern = ' [ package ] \ nname = " { } " ' . format ( crate ) <nl> <nl> for root , _ , files in os . walk ( source_dir ) : <nl> new file mode 100644 <nl> index 000000000 . . 95141a896 <nl> mmm / dev / null <nl> ppp b / build / fbcode_builder / manifests / fbthrift - rust <nl> <nl> + [ manifest ] <nl> + name = fbthrift - rust <nl> + fbsource_path = fbcode / thrift <nl> + shipit_project = fbthrift <nl> + shipit_fbcode_builder = true <nl> + <nl> + [ git ] <nl> + repo_url = https : / / github . com / facebook / fbthrift . git <nl> + <nl> + [ build ] <nl> + builder = nop <nl> + <nl> + [ shipit . pathmap ] <nl> + fbcode / thrift / public_tld = . <nl> + fbcode / thrift = thrift <nl> + <nl> + [ shipit . strip ] <nl> + ^ fbcode / thrift / thrift - config \ . h $ <nl> + ^ fbcode / thrift / perf / canary . py $ <nl> + ^ fbcode / thrift / perf / loadtest . py $ <nl> mmm a / build / fbcode_builder / manifests / mononoke <nl> ppp b / build / fbcode_builder / manifests / mononoke <nl> tools / rust / ossconfigs = . <nl> <nl> [ shipit . strip ] <nl> # strip all code unrelated to mononoke to prevent triggering unnecessary checks <nl> - ^ fbcode / eden / ( ? ! mononoke ) / . * $ <nl> + ^ fbcode / eden / ( ? ! mononoke | scm / lib / xdiff . * ) / . * $ <nl> ^ fbcode / eden / mononoke / ( ? ! public_autocargo ) . + / Cargo \ . toml $ <nl> <nl> [ dependencies ] <nl> + fbthrift - rust <nl> rust - shed <nl> <nl> [ dependencies . fb = on ] <nl> | mononoke : make mononoke_types OSS - buildable | facebook/watchman | 37db6736e027da85e93f4ecb916d7cc1d75db045 | 2020-02-24T13:21:47Z |
mmm a / hphp / hack / src / server / hackProgram . ml <nl> ppp b / hphp / hack / src / server / hackProgram . ml <nl> module Program : Server . SERVER_PROGRAM = struct <nl> | ServerMsg . SEARCH ( query , type_ ) - > <nl> ServerSearch . go query type_ oc <nl> | ServerMsg . CALC_COVERAGE path - > <nl> - ServerCoverageMetric . go path genv oc <nl> + ServerCoverageMetric . go path genv env oc <nl> <nl> let handle_connection_ genv env socket = <nl> let cli , _ = Unix . accept socket in <nl> mmm a / hphp / hack / src / server / serverCoverageMetric . ml <nl> ppp b / hphp / hack / src / server / serverCoverageMetric . ml <nl> <nl> open Coverage_level <nl> open Utils <nl> <nl> - module SE = ServerEnv <nl> - <nl> type result = level_counts trie option <nl> <nl> + module FileInfoStore = GlobalStorage . Make ( struct <nl> + type t = FileInfo . t Relative_path . Map . t <nl> + end ) <nl> + <nl> ( * Count the number of expressions of each kind of Coverage_level . * ) <nl> let count_exprs fn pos_ty_m = <nl> let pos_level_l = mk_level_list ( Some fn ) pos_ty_m in <nl> let count_exprs fn pos_ty_m = <nl> let get_coverage neutral fnl = <nl> SharedMem . invalidate_caches ( ) ; <nl> Typing_defs . accumulate_types : = true ; <nl> + let files_info = FileInfoStore . load ( ) in <nl> let file_counts = List . map begin fun fn - > <nl> - match Parser_heap . ParserHeap . get fn with <nl> + match Relative_path . Map . get fn files_info with <nl> | None - > None <nl> | Some defs - > <nl> assert ( ! Typing_defs . type_acc = [ ] ) ; <nl> - List . iter ServerIdeUtils . check_def defs ; <nl> + ServerIdeUtils . check_defs defs ; <nl> let counts = count_exprs fn ! Typing_defs . type_acc in <nl> Typing_defs . type_acc : = [ ] ; <nl> Some ( fn , counts ) <nl> let relativize root path = <nl> Some ( String . sub path root_len ( String . length path - root_len ) ) <nl> else None <nl> <nl> - let go_ fn genv = <nl> + let go_ fn genv env = <nl> let path = Path . mk_path fn in <nl> let root = Path . parent path in <nl> let module RP = Relative_path in <nl> let go_ fn genv = <nl> ( rev_rev_map ( RP . create RP . Root ) ) <nl> ( Find . make_next_files_php path ) <nl> in <nl> + FileInfoStore . store env . ServerEnv . files_info ; <nl> let result = <nl> MultiWorker . call <nl> - genv . SE . workers <nl> + genv . ServerEnv . workers <nl> ~ job : get_coverage <nl> ~ neutral : [ ] <nl> ~ merge : ( @ ) <nl> ~ next : next_files <nl> in <nl> + FileInfoStore . clear ( ) ; <nl> let relativize_list = List . map ( fun ( p , c ) - > <nl> ( relativize root ( Relative_path . to_absolute p ) | > unsafe_opt , c ) ) in <nl> let result = List . map relativize_list result in <nl> List . fold_left mk_trie None result <nl> <nl> - let go fn genv oc = <nl> + let go fn genv env oc = <nl> let result = <nl> - try go_ fn genv <nl> + try go_ fn genv env <nl> with Failure _ | Invalid_argument _ - > <nl> print_string " Coverage collection failed ! " ; <nl> None <nl> mmm a / hphp / hack / src / server / serverIdeUtils . ml <nl> ppp b / hphp / hack / src / server / serverIdeUtils . ml <nl> with e - > <nl> report_error e ; <nl> ( ) <nl> <nl> - let check_def = function <nl> - | Ast . Fun f - > <nl> - ( try Typing_check_service . type_fun ( snd f . Ast . f_name ) <nl> - with _ - > ( ) ) <nl> - | Ast . Class c - > <nl> - ( try Typing_check_service . type_class ( snd c . Ast . c_name ) <nl> - with _ - > ( ) ) <nl> - | Ast . Stmt _ - > ( ) <nl> - | Ast . Typedef { Ast . t_id = ( _ , tname ) ; _ } - > <nl> - ( try Typing_check_service . check_typedef tname <nl> - with _ - > ( ) <nl> - ) <nl> - | Ast . Constant _ - > ( ) <nl> - | Ast . Namespace _ <nl> - | Ast . NamespaceUse _ - > assert false <nl> - <nl> let check_defs { FileInfo . funs ; classes ; types ; _ } = <nl> - List . iter ( fun ( _ , x ) - > Typing_check_service . type_fun x ) funs ; <nl> - List . iter ( fun ( _ , x ) - > Typing_check_service . type_class x ) classes ; <nl> - List . iter ( fun ( _ , x ) - > Typing_check_service . check_typedef x ) types ; <nl> - ( ) <nl> + Errors . ignore_ ( fun ( ) - > <nl> + List . iter ( fun ( _ , x ) - > Typing_check_service . type_fun x ) funs ; <nl> + List . iter ( fun ( _ , x ) - > Typing_check_service . type_class x ) classes ; <nl> + List . iter ( fun ( _ , x ) - > Typing_check_service . check_typedef x ) types ; <nl> + ) <nl> <nl> let recheck fileinfo_l = <nl> SharedMem . invalidate_caches ( ) ; <nl> | Remove dependence of coverage on ParserHeap . | facebook/hhvm | 99a561167aedb60b4b1c1dc330eefef59932d10e | 2014-12-19T01:50:58Z |
mmm a / jstests / multiVersion / index_bigkeys_secondary_downgrade_during_index_build_background . js <nl> ppp b / jstests / multiVersion / index_bigkeys_secondary_downgrade_during_index_build_background . js <nl> <nl> ' use strict ' ; <nl> <nl> load ( " jstests / libs / feature_compatibility_version . js " ) ; <nl> + load ( ' jstests / noPassthrough / libs / index_build . js ' ) ; <nl> <nl> TestData . replSetFeatureCompatibilityVersion = " 4 . 2 " ; <nl> const rst = new ReplSetTest ( { nodes : [ { binVersion : ' latest ' } , { binVersion : ' latest ' } ] } ) ; <nl> <nl> { createIndexes : collName , indexes : [ { key : { x : 1 } , name : " x_1 " , background : true } ] } ) ) ; <nl> <nl> / / Make sure index build starts on the secondary . <nl> - assert . soon ( ( ) = > { <nl> - / / The currentOp entry for createIndexes looks like : <nl> - / / { . . . , <nl> - / / " command " : { " v " : 2 , <nl> - / / " key " : { x : 1 } , <nl> - / / " name " : " x_1 " , <nl> - / / " background " : true , <nl> - / / " ns " : " test . index_bigkeys_downgrade_during_index_build " } , <nl> - / / . . . <nl> - / / } <nl> - let res = secondaryDB . currentOp ( { ' command . name ' : " x_1 " } ) ; <nl> - return res [ ' ok ' ] = = = 1 & & res [ " inprog " ] . length > 0 ; <nl> - } ) ; <nl> + IndexBuildTest . waitForIndexBuildToStart ( secondaryDB ) ; <nl> <nl> / / Downgrade the FCV to 4 . 0 <nl> assert . commandWorked ( primaryDB . adminCommand ( { setFeatureCompatibilityVersion : " 4 . 0 " } ) ) ; <nl> mmm a / jstests / noPassthrough / libs / index_build . js <nl> ppp b / jstests / noPassthrough / libs / index_build . js <nl> class IndexBuildTest { <nl> let indexBuildOpId = - 1 ; <nl> <nl> result . inprog . forEach ( function ( op ) { <nl> - if ( ( op . op = = ' command ' & & ' createIndexes ' in op . command ) | | / / primary <nl> - ( op . op = = ' none ' & & ' background ' in op . command ) ) { / / secondary <nl> + if ( op . op = = ' command ' & & ' createIndexes ' in op . command ) { <nl> indexBuildOpId = op . opid ; <nl> } <nl> } ) ; <nl> mmm a / jstests / noPassthroughWithMongod / indexbg_drop . js <nl> ppp b / jstests / noPassthroughWithMongod / indexbg_drop . js <nl> <nl> - / / TODO : SERVER - 13215 move test back to replSets suite . <nl> - <nl> / * * <nl> - * TODO : SERVER - 13204 <nl> + * TODO : SERVER - 38301 <nl> * This tests inserts a huge number of documents , initiates a background index build <nl> * and tries to perform another task in parallel while the background index task is <nl> * active . The problem is that this is timing dependent and the current test setup <nl> <nl> <nl> / / Index drop race <nl> <nl> + load ( ' jstests / noPassthrough / libs / index_build . js ' ) ; <nl> + <nl> var dbname = ' dropbgindex ' ; <nl> var collection = ' jstests_feh ' ; <nl> var size = 500000 ; <nl> masterDB . getCollection ( collection ) . ensureIndex ( { b : 1 } ) ; <nl> masterDB . getCollection ( collection ) . ensureIndex ( { i : 1 } , { background : true } ) ; <nl> <nl> / / make sure the index build has started on secondary <nl> - assert . soon ( function ( ) { <nl> - var curOp = secondDB . currentOp ( ) ; <nl> - printjson ( curOp ) ; <nl> - for ( var i = 0 ; i < curOp . inprog . length ; i + + ) { <nl> - try { <nl> - if ( curOp . inprog [ i ] . command . background ) { <nl> - return true ; <nl> - } <nl> - } catch ( e ) { <nl> - / / catchem if you can <nl> - } <nl> - } <nl> - return false ; <nl> - } , " waiting for secondary bg index build " , 20000 , 10 ) ; <nl> + IndexBuildTest . waitForIndexBuildToStart ( secondDB ) ; <nl> <nl> jsTest . log ( " dropping index " ) ; <nl> masterDB . runCommand ( { dropIndexes : collection , index : " * " } ) ; <nl> mmm a / src / mongo / db / index_builder . cpp <nl> ppp b / src / mongo / db / index_builder . cpp <nl> <nl> <nl> # include " mongo / db / index_builder . h " <nl> <nl> + # include " mongo / bson / bsonobjbuilder . h " <nl> # include " mongo / db / auth / authorization_session . h " <nl> # include " mongo / db / catalog / database . h " <nl> # include " mongo / db / catalog / database_holder . h " <nl> AtomicUInt32 IndexBuilder : : _indexBuildCount ; <nl> <nl> namespace { <nl> <nl> + const StringData kIndexesFieldName = " indexes " _sd ; <nl> + const StringData kCommandName = " createIndexes " _sd ; <nl> + <nl> / * * <nl> * Returns true if writes to the catalog entry for the input namespace require being <nl> * timestamped . A ghost write is when the operation is not committed with an oplog entry and <nl> Status IndexBuilder : : _build ( OperationContext * opCtx , <nl> fassert ( 40409 , coll ) ; <nl> <nl> { <nl> + BSONObjBuilder builder ; <nl> + builder . append ( kCommandName , ns . coll ( ) ) ; <nl> + { <nl> + BSONArrayBuilder indexesBuilder ; <nl> + indexesBuilder . append ( _index ) ; <nl> + builder . append ( kIndexesFieldName , indexesBuilder . arr ( ) ) ; <nl> + } <nl> + auto opDescObj = builder . obj ( ) ; <nl> + <nl> stdx : : lock_guard < Client > lk ( * opCtx - > getClient ( ) ) ; <nl> / / Show which index we ' re building in the curop display . <nl> - CurOp : : get ( opCtx ) - > setOpDescription_inlock ( _index ) ; <nl> + auto curOp = CurOp : : get ( opCtx ) ; <nl> + curOp - > setLogicalOp_inlock ( LogicalOp : : opCommand ) ; <nl> + curOp - > setNS_inlock ( ns . ns ( ) ) ; <nl> + curOp - > setOpDescription_inlock ( opDescObj ) ; <nl> } <nl> <nl> MultiIndexBlockImpl indexer ( opCtx , coll ) ; <nl> | SERVER - 37729 IndexBuilder updates CurOp using createIndexes format | mongodb/mongo | 03e13f90426a82a97cbb0f926385e09904519259 | 2018-11-29T02:41:55Z |
mmm a / tensorflow / g3doc / get_started / os_setup . md <nl> ppp b / tensorflow / g3doc / get_started / os_setup . md <nl> For NVidia GPU support install latest NVidia drivers and <nl> $ nvidia - docker run - it - p 8888 : 8888 gcr . io / tensorflow / tensorflow : latest - gpu <nl> ` ` ` <nl> <nl> - Note : If you have a problem running ` nvidia - docker ` , you may try the old way <nl> - we have used . But it is not recomended . If you find a bug in ` nvidia - docker ` , report <nl> - it there please and try using the ` nvidia - docker ` as described above . <nl> - <nl> - $ export CUDA_SO = $ ( \ ls / usr / lib / x86_64 - linux - gnu / libcuda . * | xargs - I { } echo ' - v { } : { } ' ) <nl> - $ export DEVICES = $ ( \ ls / dev / nvidia * | xargs - I { } echo ' - - device { } : { } ' ) <nl> - $ docker run - it - p 8888 : 8888 $ CUDA_SO $ DEVICES gcr . io / tensorflow / tensorflow : latest - gpu <nl> + If you run into a problem running ` nvidia - docker ` , Please report an issue <nl> + [ here ] ( https : / / github . com / NVIDIA / nvidia - docker / issues ) . <nl> <nl> For more details see [ TensorFlow docker <nl> readme ] ( https : / / github . com / tensorflow / tensorflow / tree / master / tensorflow / tools / docker ) . <nl> | Merge pull request from gunan / patch | tensorflow/tensorflow | 25f072f768ca2995d8f9c675767f3971a085c11f | 2016-12-29T22:18:30Z |
mmm a / brightray / browser / inspectable_web_contents_impl . cc <nl> ppp b / brightray / browser / inspectable_web_contents_impl . cc <nl> InspectableWebContentsImpl : : InspectableWebContentsImpl ( <nl> } <nl> <nl> InspectableWebContentsImpl : : ~ InspectableWebContentsImpl ( ) { <nl> + if ( devtools_web_contents_ ) <nl> + devtools_web_contents_ - > Close ( ) ; <nl> Observe ( nullptr ) ; <nl> } <nl> <nl> | Merge pull request from electron / devtools_shutdown_patch_revert_revert | electron/electron | bd5c53c2f70029d3ef862f51702cb39c0b69173f | 2017-03-28T05:46:06Z |
mmm a / Marlin / language . h <nl> ppp b / Marlin / language . h <nl> <nl> / / 9 Finnish <nl> / / 10 Aragonese <nl> / / 11 Dutch <nl> + / / 12 Catalan <nl> <nl> # ifndef LANGUAGE_CHOICE <nl> # define LANGUAGE_CHOICE 1 / / Pick your language from the list above <nl> <nl> <nl> # endif <nl> <nl> + <nl> + # if LANGUAGE_CHOICE = = 12 <nl> + <nl> + / / LCD Menu Messages <nl> + <nl> + / / Please note these are limited to 17 characters ! <nl> + <nl> + # define WELCOME_MSG MACHINE_NAME " preparada . " <nl> + # define MSG_SD_INSERTED " SD detectada . " <nl> + # define MSG_SD_REMOVED " SD expulsada . " <nl> + # define MSG_MAIN " Menu principal " <nl> + # define MSG_AUTOSTART " Inici automatic " <nl> + # define MSG_DISABLE_STEPPERS " Apagar motors " <nl> + # define MSG_AUTO_HOME " Home global " <nl> + # define MSG_SET_ORIGIN " Establir origen " <nl> + # define MSG_PREHEAT_PLA " Preescalfar PLA " <nl> + # define MSG_PREHEAT_PLA0 " Preescalfar PLA 1 " <nl> + # define MSG_PREHEAT_PLA1 " Preescalfar PLA 2 " <nl> + # define MSG_PREHEAT_PLA2 " Preescalfar PLA 3 " <nl> + # define MSG_PREHEAT_PLA012 " Preesc . tot PLA " <nl> + # define MSG_PREHEAT_PLA_BEDONLY " Preesc . llit PLA " <nl> + # define MSG_PREHEAT_PLA_SETTINGS " Configuració PLA " <nl> + # define MSG_PREHEAT_ABS " Preescalfar ABS " <nl> + # define MSG_PREHEAT_ABS0 " Preescalfar ABS 1 " <nl> + # define MSG_PREHEAT_ABS1 " Preescalfar ABS 2 " <nl> + # define MSG_PREHEAT_ABS2 " Preescalfar ABS 3 " <nl> + # define MSG_PREHEAT_ABS012 " Preesc . tot ABS " <nl> + # define MSG_PREHEAT_ABS_BEDONLY " Preesc . llit ABS " <nl> + # define MSG_PREHEAT_ABS_SETTINGS " Configuració ABS " <nl> + # define MSG_COOLDOWN " Refredar " <nl> + # define MSG_SWITCH_PS_ON " Switch power on " <nl> + # define MSG_SWITCH_PS_OFF " Switch power off " <nl> + # define MSG_EXTRUDE " Extruir " <nl> + # define MSG_RETRACT " Refredar " <nl> + # define MSG_MOVE_AXIS " Moure eixos " <nl> + # define MSG_MOVE_X " Moure X " <nl> + # define MSG_MOVE_Y " Moure Y " <nl> + # define MSG_MOVE_Z " Moure Z " <nl> + # define MSG_MOVE_E " Extrusor " <nl> + # define MSG_MOVE_01MM " Moure 0 . 1mm " <nl> + # define MSG_MOVE_1MM " Moure 1mm " <nl> + # define MSG_MOVE_10MM " Moure 10mm " <nl> + # define MSG_SPEED " Velocitat " <nl> + # define MSG_NOZZLE " Nozzle " <nl> + # define MSG_NOZZLE1 " Nozzle2 " <nl> + # define MSG_NOZZLE2 " Nozzle3 " <nl> + # define MSG_BED " Llit " <nl> + # define MSG_FAN_SPEED " Vel . Ventilador " <nl> + # define MSG_FLOW " Fluxe " <nl> + # define MSG_FLOW0 " Fluxe 0 " <nl> + # define MSG_FLOW1 " Fluxe 1 " <nl> + # define MSG_FLOW2 " Fluxe 2 " <nl> + # define MSG_CONTROL " Control " <nl> + # define MSG_MIN " \ 002 Min " <nl> + # define MSG_MAX " \ 002 Max " <nl> + # define MSG_FACTOR " \ 002 Fact " <nl> + # define MSG_AUTOTEMP " Autotemp " <nl> + # define MSG_ON " On " <nl> + # define MSG_OFF " Off " <nl> + # define MSG_PID_P " PID - P " <nl> + # define MSG_PID_I " PID - I " <nl> + # define MSG_PID_D " PID - D " <nl> + # define MSG_PID_C " PID - C " <nl> + # define MSG_ACC " Accel " <nl> + # define MSG_VXY_JERK " Vxy - jerk " <nl> + # define MSG_VZ_JERK " Vz - jerk " <nl> + # define MSG_VE_JERK " Ve - jerk " <nl> + # define MSG_VMAX " Vmax " <nl> + # define MSG_X " x " <nl> + # define MSG_Y " y " <nl> + # define MSG_Z " z " <nl> + # define MSG_E " e " <nl> + # define MSG_VMIN " Vmin " <nl> + # define MSG_VTRAV_MIN " VTrav min " <nl> + # define MSG_AMAX " Amax " <nl> + # define MSG_A_RETRACT " A - retract " <nl> + # define MSG_XSTEPS " Xpassos / mm " <nl> + # define MSG_YSTEPS " Ypassos / mm " <nl> + # define MSG_ZSTEPS " Zpassos / mm " <nl> + # define MSG_ESTEPS " Epassos / mm " <nl> + # define MSG_RECTRACT " Retreure " <nl> + # define MSG_TEMPERATURE " Temperatura " <nl> + # define MSG_MOTION " Moviment " <nl> + # define MSG_CONTRAST " Contrast de LCD " <nl> + # define MSG_STORE_EPROM " Desar a memoria " <nl> + # define MSG_LOAD_EPROM " Carregar de mem . " <nl> + # define MSG_RESTORE_FAILSAFE " Rest . emergencia " <nl> + # define MSG_REFRESH " Refrescar " <nl> + # define MSG_WATCH " Pantalla Info . " <nl> + # define MSG_PREPARE " Preparar " <nl> + # define MSG_TUNE " Calibrar " <nl> + # define MSG_PAUSE_PRINT " Pausa imp . " <nl> + # define MSG_RESUME_PRINT " Reprendre imp . " <nl> + # define MSG_STOP_PRINT " Parar inp . " <nl> + # define MSG_CARD_MENU " Imprimir de SD " <nl> + # define MSG_NO_CARD " - Sense targeta SD " <nl> + # define MSG_DWELL " Repos . . . " <nl> + # define MSG_USERWAIT " Esperant usuari . . " <nl> + # define MSG_RESUMING " Reprenent imp . " <nl> + # define MSG_NO_MOVE " Sense moviment . " <nl> + # define MSG_KILLED " PARADA DE EMERG . " <nl> + # define MSG_STOPPED " ATURAT . " <nl> + # define MSG_CONTROL_RETRACT " Retreure mm " <nl> + # define MSG_CONTROL_RETRACTF " Retreure F " <nl> + # define MSG_CONTROL_RETRACT_ZLIFT " Aixecar mm " <nl> + # define MSG_CONTROL_RETRACT_RECOVER " DesRet + mm " <nl> + # define MSG_CONTROL_RETRACT_RECOVERF " DesRet F " <nl> + # define MSG_AUTORETRACT " AutoRetr . " <nl> + # define MSG_FILAMENTCHANGE " Canviar filament " <nl> + # define MSG_INIT_SDCARD " Iniciant SD " <nl> + # define MSG_CNG_SDCARD " Canviar SD " <nl> + # define MSG_ZPROBE_OUT " Z probe out . bed " <nl> + # define MSG_POSITION_UNKNOWN " Home X / Y abans Z " <nl> + # define MSG_ZPROBE_ZOFFSET " Z Offset " <nl> + # define MSG_BABYSTEP_X " Babystep X " <nl> + # define MSG_BABYSTEP_Y " Babystep Y " <nl> + # define MSG_BABYSTEP_Z " Babystep Z " <nl> + # define MSG_ENDSTOP_ABORT " Endstop abort " <nl> + <nl> + / / Serial Console Messages <nl> + <nl> + # define MSG_Enqueing " en cua \ " " <nl> + # define MSG_POWERUP " PowerUp " <nl> + # define MSG_EXTERNAL_RESET " Reset Extern " <nl> + # define MSG_BROWNOUT_RESET " Reset per Voltatge Incorrecte " <nl> + # define MSG_WATCHDOG_RESET " Reset per Bloqueix " <nl> + # define MSG_SOFTWARE_RESET " Reset per Software " <nl> + # define MSG_AUTHOR " | Author : " <nl> + # define MSG_CONFIGURATION_VER " Ultima actualitzacio : " <nl> + # define MSG_FREE_MEMORY " Memoria lliure : " <nl> + # define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes : " <nl> + # define MSG_OK " ok " <nl> + # define MSG_FILE_SAVED " Fitxer desat . " <nl> + # define MSG_ERR_LINE_NO " El Numero de la Linia no es igual al Ultimo Numero de Linia + 1 , Ultima Linia : " <nl> + # define MSG_ERR_CHECKSUM_MISMATCH " el checksum no coincideix , Ultima Linia : " <nl> + # define MSG_ERR_NO_CHECKSUM " No s ' ha trobat el Checksum amb el numero de linea , Ultima Linea : " <nl> + # define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM " No s ' ha trobat Numero de Linea amb el Checksum , Ultima Linea : " <nl> + # define MSG_FILE_PRINTED " Impresio acabada " <nl> + # define MSG_BEGIN_FILE_LIST " Inici de la llista d ' arxius " <nl> + # define MSG_END_FILE_LIST " Fi de la llista d ' arxius " <nl> + # define MSG_M104_INVALID_EXTRUDER " M104 Extrusor Invalid " <nl> + # define MSG_M105_INVALID_EXTRUDER " M105 Extrusor Invalid " <nl> + # define MSG_M200_INVALID_EXTRUDER " M200 Extrusor Invalid " <nl> + # define MSG_M218_INVALID_EXTRUDER " M218 Extrusor Invalid " <nl> + # define MSG_M221_INVALID_EXTRUDER " M221 Extrusor Invalid " <nl> + # define MSG_ERR_NO_THERMISTORS " No hi ha termistors - sense temperatura " <nl> + # define MSG_M109_INVALID_EXTRUDER " M109 Extrusor Invalid " <nl> + # define MSG_HEATING " Escalfant . . . " <nl> + # define MSG_HEATING_COMPLETE " Escalfament acabat . " <nl> + # define MSG_BED_HEATING " Escalfant llit . " <nl> + # define MSG_BED_DONE " Llit Calent . " <nl> + # define MSG_M115_REPORT " FIRMWARE_NAME : Marlin V1 ; Sprinter / grbl mashup for gen6 FIRMWARE_URL : " FIRMWARE_URL " PROTOCOL_VERSION : " PROTOCOL_VERSION " MACHINE_TYPE : " MACHINE_NAME " EXTRUDER_COUNT : " STRINGIFY ( EXTRUDERS ) " UUID : " MACHINE_UUID " \ n " <nl> + # define MSG_COUNT_X " Count X : " <nl> + # define MSG_ERR_KILLED " Impressora Parada per kill ( ) ! " <nl> + # define MSG_ERR_STOPPED " Impressora Parada per errors . Repara l ' error i utilitza M999 per reiniciar ! . ( Hi ha un reset de temperatura , cal ajustarla abans de continuuar ) " <nl> + # define MSG_RESEND " Reenviar : " <nl> + # define MSG_UNKNOWN_COMMAND " Comanda Desconeguda : \ " " <nl> + # define MSG_ACTIVE_EXTRUDER " Extrusor Actiu : " <nl> + # define MSG_INVALID_EXTRUDER " Extrusor Invalid " <nl> + # define MSG_X_MIN " x_min : " <nl> + # define MSG_X_MAX " x_max : " <nl> + # define MSG_Y_MIN " y_min : " <nl> + # define MSG_Y_MAX " y_max : " <nl> + # define MSG_Z_MIN " z_min : " <nl> + # define MSG_Z_MAX " z_max : " <nl> + # define MSG_M119_REPORT " Comprobant finals de carrera . " <nl> + # define MSG_ENDSTOP_HIT " Activat " <nl> + # define MSG_ENDSTOP_OPEN " obert " <nl> + # define MSG_HOTEND_OFFSET " Hotend offsets : " <nl> + <nl> + # define MSG_SD_CANT_OPEN_SUBDIR " No s ' ha pogut obrir la carpeta " <nl> + # define MSG_SD_INIT_FAIL " Error al iniciar la SD " <nl> + # define MSG_SD_VOL_INIT_FAIL " Error al montar el volum " <nl> + # define MSG_SD_OPENROOT_FAIL " Error al obrir la carpeta arrel " <nl> + # define MSG_SD_CARD_OK " Targeta SD OK " <nl> + # define MSG_SD_WORKDIR_FAIL " Error al obrir la carpeta de treball " <nl> + # define MSG_SD_OPEN_FILE_FAIL " Error al obrir , Fitxer : " <nl> + # define MSG_SD_FILE_OPENED " Fitxer obert : " <nl> + # define MSG_SD_SIZE " Mida : " <nl> + # define MSG_SD_FILE_SELECTED " Fitxer Seleccionat " <nl> + # define MSG_SD_WRITE_TO_FILE " Desant al fitxer : " <nl> + # define MSG_SD_PRINTING_BYTE " SD imprimint el byte " <nl> + # define MSG_SD_NOT_PRINTING " No s ' està imprimint amb SD " <nl> + # define MSG_SD_ERR_WRITE_TO_FILE " Error al esciure al fitxer " <nl> + # define MSG_SD_CANT_ENTER_SUBDIR " No es pot obrir la carpeta : " <nl> + <nl> + # define MSG_STEPPER_TOO_HIGH " Steprate massa alt : " <nl> + # define MSG_ENDSTOPS_HIT " S ' ha tocat el final de carrera : " <nl> + # define MSG_ERR_COLD_EXTRUDE_STOP " extrusio freda evitada " <nl> + # define MSG_ERR_LONG_EXTRUDE_STOP " extrusio massa llarga evitada " <nl> + # define MSG_BABYSTEPPING_X " Babystepping X " <nl> + # define MSG_BABYSTEPPING_Y " Babystepping Y " <nl> + # define MSG_BABYSTEPPING_Z " Babystepping Z " <nl> + # define MSG_SERIAL_ERROR_MENU_STRUCTURE " Error a l ' estructura dels menus " <nl> + <nl> + # endif <nl> + <nl> + <nl> # endif / / ifndef LANGUAGE_H <nl> | Merge pull request from pixatintes / patch - 1 | MarlinFirmware/Marlin | 086ff1644f5ac608bea70ba7f341ef0bfceddda9 | 2014-04-12T23:46:17Z |
mmm a / Telegram / SourceFiles / auth_session . cpp <nl> ppp b / Telegram / SourceFiles / auth_session . cpp <nl> void AuthSessionData : : constructFromSerialized ( const QByteArray & serialized ) { <nl> <nl> AuthSession : : AuthSession ( UserId userId ) <nl> : _userId ( userId ) <nl> + , _autoLockTimer ( [ this ] { checkAutoLock ( ) ; } ) <nl> , _api ( std : : make_unique < ApiWrap > ( ) ) <nl> , _downloader ( std : : make_unique < Storage : : Downloader > ( ) ) <nl> - , _notifications ( std : : make_unique < Window : : Notifications : : System > ( this ) ) <nl> - , _autoLockTimer ( [ this ] { checkAutoLock ( ) ; } ) { <nl> + , _notifications ( std : : make_unique < Window : : Notifications : : System > ( this ) ) { <nl> Expects ( _userId ! = 0 ) ; <nl> _saveDataTimer . setCallback ( [ this ] { <nl> Local : : writeUserSettings ( ) ; <nl> | Alpha 1 . 0 . 33 : Fix build for Xcode . | telegramdesktop/tdesktop | f619afc4c6641694ecc140fb0f9e8ccafcc0125a | 2017-04-15T21:45:25Z |
mmm a / HelloLua / android / jni / helloworld / main . cpp <nl> ppp b / HelloLua / android / jni / helloworld / main . cpp <nl> <nl> <nl> using namespace cocos2d ; <nl> <nl> - # define IMG_PATH " assets " <nl> - <nl> extern " C " <nl> { <nl> <nl> void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit ( JNIEnv * env , jobject thi <nl> view - > create ( 480 , 320 ) ; <nl> cocos2d : : CCDirector : : sharedDirector ( ) - > setOpenGLView ( view ) ; <nl> <nl> - CCFileUtils : : setRelativePath ( IMG_PATH ) ; <nl> - <nl> AppDelegate * pAppDelegate = new AppDelegate ( ) ; <nl> cocos2d : : CCApplication : : sharedApplication ( ) . run ( ) ; <nl> } <nl> mmm a / HelloWorld / AppDelegate . cpp <nl> ppp b / HelloWorld / AppDelegate . cpp <nl> bool AppDelegate : : initInstance ( ) <nl> / / OpenGLView initialized in HelloWorld / android / jni / helloworld / main . cpp <nl> / / the default setting is to create a fullscreen view <nl> / / if you want to use auto - scale , please enable view - > create ( 320 , 480 ) in main . cpp <nl> + / / if the resources under ' / sdcard " or other writeable path , set it . <nl> + / / warning : the audio source should in assets / <nl> + / / cocos2d : : CCFileUtils : : setResourcePath ( " / sdcard " ) ; <nl> <nl> # endif / / CC_PLATFORM_ANDROID <nl> <nl> mmm a / HelloWorld / android / jni / helloworld / main . cpp <nl> ppp b / HelloWorld / android / jni / helloworld / main . cpp <nl> <nl> <nl> using namespace cocos2d ; <nl> <nl> - # define IMG_PATH " assets " <nl> - <nl> extern " C " <nl> { <nl> <nl> void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit ( JNIEnv * env , jobject thi <nl> / / view - > create ( 480 , 320 ) ; <nl> cocos2d : : CCDirector : : sharedDirector ( ) - > setOpenGLView ( view ) ; <nl> <nl> - CCFileUtils : : setRelativePath ( IMG_PATH ) ; <nl> - <nl> AppDelegate * pAppDelegate = new AppDelegate ( ) ; <nl> cocos2d : : CCApplication : : sharedApplication ( ) . run ( ) ; <nl> } <nl> mmm a / cocos2dx / platform / CCFileUtils . h <nl> ppp b / cocos2dx / platform / CCFileUtils . h <nl> class CC_DLL CCFileUtils <nl> * / <nl> static void setResource ( const char * pszZipFileName ) ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / interfaces on android <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - static const char * getResourcePath ( void ) ; <nl> - static void setRelativePath ( const char * pszRelativePath ) ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / interfaces on ios <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / cocos2dx / platform / android / CCFileUtils_android . cpp <nl> ppp b / cocos2dx / platform / android / CCFileUtils_android . cpp <nl> NS_CC_BEGIN ; <nl> <nl> # define MAX_PATH 256 <nl> <nl> + using namespace std ; <nl> + <nl> / / record the resource path <nl> - static std : : string s_strRelativePath = " " ; <nl> - static std : : string s_strResourcePath = " " ; <nl> + static string s_strResourcePath = " " ; <nl> <nl> - void CCFileUtils : : setRelativePath ( const char * pszRelativePath ) <nl> + void CCFileUtils : : setResourcePath ( const char * pszResourcePath ) <nl> { <nl> - CCAssert ( pszRelativePath ! = NULL , " [ FileUtils setRelativePath ] - - wrong relative path " ) ; <nl> + CCAssert ( pszResourcePath ! = NULL , " [ FileUtils setRelativePath ] - - wrong relative path " ) ; <nl> <nl> - if ( ! pszRelativePath ) <nl> + if ( ! pszResourcePath ) <nl> { <nl> return ; <nl> } <nl> <nl> - s_strRelativePath = pszRelativePath ; <nl> - <nl> - / / if the path is not ended with ' / ' , append it <nl> - if ( s_strRelativePath . find ( " / " ) ! = ( strlen ( s_strRelativePath . c_str ( ) ) - 1 ) ) <nl> + s_strResourcePath = pszResourcePath ; <nl> + <nl> + / * <nl> + * If the path is set by user , and not end with " / " , append it <nl> + * / <nl> + if ( s_strResourcePath . find ( " . apk " ) = = string : : npos <nl> + & & s_strResourcePath . find_last_of ( " / " ) ! = s_strResourcePath . length ( ) - 1 ) <nl> { <nl> - s_strRelativePath + = " / " ; <nl> + s_strResourcePath + = " / " ; <nl> } <nl> } <nl> <nl> - void CCFileUtils : : setResourcePath ( const char * pszResourcePath ) <nl> - { <nl> - CCAssert ( pszResourcePath ! = NULL , " [ FileUtils setResourcePath ] - - wrong resource path " ) ; <nl> - CCAssert ( strlen ( pszResourcePath ) < = MAX_PATH , " [ FileUtils setResourcePath ] - - resource path too long " ) ; <nl> - <nl> - s_strResourcePath = pszResourcePath ; <nl> - } <nl> - <nl> - const char * CCFileUtils : : getResourcePath ( ) <nl> - { <nl> - return s_strResourcePath . c_str ( ) ; <nl> - } <nl> - <nl> const char * CCFileUtils : : fullPathFromRelativePath ( const char * pszRelativePath ) <nl> { <nl> - return pszRelativePath ; <nl> + if ( s_strResourcePath . find ( " . apk " ) ! = string : : npos ) <nl> + { <nl> + return pszRelativePath ; <nl> + } <nl> + else <nl> + { <nl> + CCString * pRet = new CCString ( ) ; <nl> + pRet - > autorelease ( ) ; <nl> + pRet - > m_sString = s_strResourcePath + pszRelativePath ; <nl> + return pRet - > m_sString . c_str ( ) ; <nl> + } <nl> } <nl> <nl> const char * CCFileUtils : : fullPathFromRelativeFile ( const char * pszFilename , const char * pszRelativeFile ) <nl> { <nl> - / / std : : string relativeFile = fullPathFromRelativePath ( pszRelativeFile ) ; <nl> std : : string relativeFile = pszRelativeFile ; <nl> CCString * pRet = new CCString ( ) ; <nl> pRet - > autorelease ( ) ; <nl> const char * CCFileUtils : : fullPathFromRelativeFile ( const char * pszFilename , const <nl> } <nl> <nl> unsigned char * CCFileUtils : : getFileData ( const char * pszFileName , const char * pszMode , unsigned long * pSize ) <nl> - { <nl> - string fullPath = s_strRelativePath + pszFileName ; <nl> - unsigned char * pData = CCFileUtils : : getFileDataFromZip ( s_strResourcePath . c_str ( ) , fullPath . c_str ( ) , pSize ) ; <nl> + { <nl> + string fullPath = pszFileName ; <nl> + unsigned char * pData = 0 ; <nl> + <nl> + if ( s_strResourcePath . find ( " . apk " ) ! = string : : npos ) <nl> + { <nl> + / / read from apk <nl> + fullPath . insert ( 0 , " assets / " ) ; <nl> + pData = CCFileUtils : : getFileDataFromZip ( s_strResourcePath . c_str ( ) , fullPath . c_str ( ) , pSize ) ; <nl> + } <nl> + else <nl> + { <nl> + do <nl> + { <nl> + / / read rrom other path than user set it <nl> + FILE * fp = fopen ( pszFileName , pszMode ) ; <nl> + CC_BREAK_IF ( ! fp ) ; <nl> + <nl> + fseek ( fp , 0 , SEEK_END ) ; <nl> + * pSize = ftell ( fp ) ; <nl> + fseek ( fp , 0 , SEEK_SET ) ; <nl> + pData = new unsigned char [ * pSize ] ; <nl> + * pSize = fread ( pData , sizeof ( unsigned char ) , * pSize , fp ) ; <nl> + fclose ( fp ) ; <nl> + } while ( 0 ) ; <nl> + } <nl> + <nl> if ( ! pData & & getIsPopupNotify ( ) ) <nl> { <nl> std : : string title = " Notification " ; <nl> std : : string msg = " Get data from file ( " ; <nl> - msg . append ( pszFileName ) . append ( " ) failed ! " ) ; <nl> + msg . append ( fullPath . c_str ( ) ) . append ( " ) failed ! " ) ; <nl> CCMessageBox ( msg . c_str ( ) , title . c_str ( ) ) ; <nl> } <nl> return pData ; <nl> mmm a / cocos2dx / platform / ios / CCFileUtils_ios . mm <nl> ppp b / cocos2dx / platform / ios / CCFileUtils_ios . mm <nl> static void static_addValueToCCDict ( id key , id value , CCDictionary < std : : string , <nl> <nl> strcpy ( s_pszResourcePath , pszResourcePath ) ; <nl> } <nl> - <nl> - const char * CCFileUtils : : getResourcePath ( ) <nl> - { <nl> - return s_pszResourcePath ; <nl> - } <nl> - <nl> + <nl> int CCFileUtils : : ccLoadFileIntoMemory ( const char * filename , unsigned char * * out ) <nl> { <nl> CCAssert ( out , " ccLoadFileIntoMemory : invalid ' out ' parameter " ) ; <nl> static void static_addValueToCCDict ( id key , id value , CCDictionary < std : : string , <nl> { <nl> CCAssert ( 0 , " Have not implement ! " ) ; <nl> } <nl> - void CCFileUtils : : setRelativePath ( const char * pszRelativePath ) <nl> - { <nl> - CCAssert ( 0 , " Have not implement ! " ) ; <nl> - } <nl> <nl> / / notification support when getFileData from a invalid file <nl> static bool s_bPopupNotify = true ; <nl> mmm a / cocos2dx / platform / win32 / CCFileUtils_win32 . cpp <nl> ppp b / cocos2dx / platform / win32 / CCFileUtils_win32 . cpp <nl> void CCFileUtils : : setResource ( const char * pszZipFileName ) <nl> CCAssert ( 0 , " Have not implement ! " ) ; <nl> } <nl> <nl> - const char * CCFileUtils : : getResourcePath ( void ) <nl> - { <nl> - CCAssert ( 0 , " Have not implement ! " ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - void CCFileUtils : : setRelativePath ( const char * pszRelativePath ) <nl> - { <nl> - CC_UNUSED_PARAM ( pszRelativePath ) ; <nl> - CCAssert ( 0 , " Have not implement ! " ) ; <nl> - } <nl> - <nl> string CCFileUtils : : getWriteablePath ( ) <nl> { <nl> / / return the path that the exe file saved in <nl> mmm a / cocos2dx / platform / wophone / CCFileUtils_wophone . cpp <nl> ppp b / cocos2dx / platform / wophone / CCFileUtils_wophone . cpp <nl> void CCFileUtils : : setResourcePath ( const char * pszResourcePath ) <nl> CCAssert ( 0 , " Have not implement ! " ) ; <nl> } <nl> <nl> - const char * CCFileUtils : : getResourcePath ( void ) <nl> - { <nl> - CCAssert ( 0 , " Have not implement ! " ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - void CCFileUtils : : setRelativePath ( const char * pszRelativePath ) <nl> - { <nl> - CCAssert ( 0 , " Have not implement ! " ) ; <nl> - } <nl> - <nl> string CCFileUtils : : getWriteablePath ( ) <nl> { <nl> return string ( CCApplication : : sharedApplication ( ) . getAppWritablePath ( ) ) ; <nl> mmm a / tests / test . android / jni / tests / main . cpp <nl> ppp b / tests / test . android / jni / tests / main . cpp <nl> <nl> <nl> using namespace cocos2d ; <nl> <nl> - # define IMG_PATH " assets " <nl> - <nl> extern " C " <nl> { <nl> <nl> void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit ( JNIEnv * env , jobject thi <nl> / / view - > create ( 480 , 320 ) ; <nl> cocos2d : : CCDirector : : sharedDirector ( ) - > setOpenGLView ( view ) ; <nl> <nl> - CCFileUtils : : setRelativePath ( IMG_PATH ) ; <nl> - <nl> AppDelegate * pAppDelegate = new AppDelegate ( ) ; <nl> cocos2d : : CCApplication : : sharedApplication ( ) . run ( ) ; <nl> } <nl> | Merge pull request from minggo / iss656 | cocos2d/cocos2d-x | 4d1a1629de45a320f956b5782f926fed8c70677e | 2011-08-04T09:26:23Z |
mmm a / js / server / modules / @ arangodb / replication . js <nl> ppp b / js / server / modules / @ arangodb / replication . js <nl> <nl> - / * global ArangoServerState , ERRORS * / <nl> + / * global ArangoServerState * / <nl> ' use strict ' ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> var internal = require ( ' internal ' ) ; <nl> + var ERRORS = internal . errors ; <nl> var endpointToURL = require ( ' @ arangodb / cluster ' ) . endpointToURL ; <nl> var request ; <nl> if ( ArangoServerState . role ( ) = = = ' PRIMARY ' ) { <nl> | Fix access to global ERRORS table . | arangodb/arangodb | 1e77d6abca51ce925e6869266d83d9f5a3f15971 | 2017-01-19T15:04:35Z |
mmm a / tests / tests / ParticleTest / ParticleTest . cpp <nl> ppp b / tests / tests / ParticleTest / ParticleTest . cpp <nl> enum <nl> <nl> static int sceneIdx = - 1 ; <nl> <nl> - # define MAX_LAYER 41 <nl> + # define MAX_LAYER 43 <nl> <nl> CCLayer * createParticleLayer ( int nIndex ) <nl> { <nl> CCLayer * createParticleLayer ( int nIndex ) <nl> case 38 : return new MultipleParticleSystemsBatched ( ) ; <nl> case 39 : return new AddAndDeleteParticleSystems ( ) ; <nl> case 40 : return new ReorderParticleSystems ( ) ; <nl> + case 41 : return new PremultipliedAlphaTest ( ) ; <nl> + case 42 : return new PremultipliedAlphaTest2 ( ) ; <nl> default : <nl> break ; <nl> } <nl> void ParticleDemo : : onEnter ( void ) <nl> CCMenu * menu = CCMenu : : menuWithItems ( item1 , item2 , item3 , item4 , NULL ) ; <nl> <nl> menu - > setPosition ( CCPointZero ) ; <nl> - item1 - > setPosition ( CCPointMake ( s . width / 2 - 100 , 30 ) ) ; <nl> - item2 - > setPosition ( CCPointMake ( s . width / 2 , 30 ) ) ; <nl> - item3 - > setPosition ( CCPointMake ( s . width / 2 + 100 , 30 ) ) ; <nl> - item4 - > setPosition ( CCPointMake ( 0 , 100 ) ) ; <nl> - item4 - > setAnchorPoint ( CCPointMake ( 0 , 0 ) ) ; <nl> + item1 - > setPosition ( ccp ( s . width / 2 - item2 - > getContentSize ( ) . width * 2 , item2 - > getContentSize ( ) . height / 2 ) ) ; <nl> + item2 - > setPosition ( ccp ( s . width / 2 , item2 - > getContentSize ( ) . height / 2 ) ) ; <nl> + item3 - > setPosition ( ccp ( s . width / 2 + item2 - > getContentSize ( ) . width * 2 , item2 - > getContentSize ( ) . height / 2 ) ) ; <nl> + item4 - > setPosition ( ccp ( 0 , 100 ) ) ; <nl> + item4 - > setAnchorPoint ( ccp ( 0 , 0 ) ) ; <nl> <nl> addChild ( menu , 100 ) ; <nl> <nl> CCLabelAtlas * labelAtlas = CCLabelAtlas : : labelWithString ( " 0000 " , " fps_images . png " , 12 , 32 , ' . ' ) ; <nl> addChild ( labelAtlas , 100 , kTagParticleCount ) ; <nl> - labelAtlas - > setPosition ( CCPointMake ( s . width - 66 , 50 ) ) ; <nl> + labelAtlas - > setPosition ( ccp ( s . width - 66 , 50 ) ) ; <nl> <nl> / / moving background <nl> m_background = CCSprite : : spriteWithFile ( s_back3 ) ; <nl> addChild ( m_background , 5 ) ; <nl> - m_background - > setPosition ( CCPointMake ( s . width / 2 , s . height - 180 ) ) ; <nl> + m_background - > setPosition ( ccp ( s . width / 2 , s . height - 180 ) ) ; <nl> <nl> - CCActionInterval * move = CCMoveBy : : actionWithDuration ( 4 , CCPointMake ( 300 , 0 ) ) ; <nl> + CCActionInterval * move = CCMoveBy : : actionWithDuration ( 4 , ccp ( 300 , 0 ) ) ; <nl> CCActionInterval * move_back = move - > reverse ( ) ; <nl> CCFiniteTimeAction * seq = CCSequence : : actions ( move , move_back , NULL ) ; <nl> m_background - > runAction ( CCRepeatForever : : actionWithAction ( ( CCActionInterval * ) seq ) ) ; <nl> std : : string ReorderParticleSystems : : subtitle ( ) <nl> { <nl> return " changes every 2 seconds " ; <nl> } <nl> - <nl> + <nl> + / / PremultipliedAlphaTest <nl> + <nl> + std : : string PremultipliedAlphaTest : : title ( ) <nl> + { <nl> + return " premultiplied alpha " ; <nl> + } <nl> + <nl> + std : : string PremultipliedAlphaTest : : subtitle ( ) <nl> + { <nl> + return " no black halo , particles should fade out " ; <nl> + } <nl> + <nl> + void PremultipliedAlphaTest : : onEnter ( ) <nl> + { <nl> + ParticleDemo : : onEnter ( ) ; <nl> + <nl> + this - > setColor ( ccBLUE ) ; <nl> + this - > removeChild ( m_background , true ) ; <nl> + m_background = NULL ; <nl> + <nl> + m_emitter = CCParticleSystemQuad : : particleWithFile ( " Particles / BoilingFoam . plist " ) ; <nl> + m_emitter - > retain ( ) ; <nl> + / / Particle Designer " normal " blend func causes black halo on premul textures ( ignores multiplication ) <nl> + / / this - > emitter . blendFunc = ( ccBlendFunc ) { GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA } ; <nl> + <nl> + / / Cocos2d " normal " blend func for premul causes alpha to be ignored ( oversaturates colors ) <nl> + ccBlendFunc tBlendFunc = { GL_ONE , GL_ONE_MINUS_SRC_ALPHA } ; <nl> + m_emitter - > setBlendFunc ( tBlendFunc ) ; <nl> + <nl> + CCAssert ( m_emitter - > getOpacityModifyRGB ( ) , " Particle texture does not have premultiplied alpha , test is useless " ) ; <nl> + <nl> + / / Toggle next line to see old behavior <nl> + / / this - > emitter . opacityModifyRGB = NO ; <nl> + <nl> + m_emitter - > setStartColor ( ccc4f ( 1 , 1 , 1 , 1 ) ) ; <nl> + m_emitter - > setEndColor ( ccc4f ( 1 , 1 , 1 , 0 ) ) ; <nl> + m_emitter - > setStartColorVar ( ccc4f ( 0 , 0 , 0 , 0 ) ) ; <nl> + m_emitter - > setEndColorVar ( ccc4f ( 0 , 0 , 0 , 0 ) ) ; <nl> + <nl> + this - > addChild ( m_emitter , 10 ) ; <nl> + } <nl> + <nl> + / / PremultipliedAlphaTest2 <nl> + <nl> + void PremultipliedAlphaTest2 : : onEnter ( ) <nl> + { <nl> + ParticleDemo : : onEnter ( ) ; <nl> + <nl> + this - > setColor ( ccBLACK ) ; <nl> + this - > removeChild ( m_background , true ) ; <nl> + m_background = NULL ; <nl> + <nl> + m_emitter = CCParticleSystemQuad : : particleWithFile ( " Particles / TestPremultipliedAlpha . plist " ) ; <nl> + m_emitter - > retain ( ) ; <nl> + this - > addChild ( m_emitter , 10 ) ; <nl> + } <nl> + <nl> + std : : string PremultipliedAlphaTest2 : : title ( ) <nl> + { <nl> + return " premultiplied alpha 2 " ; <nl> + } <nl> + <nl> + std : : string PremultipliedAlphaTest2 : : subtitle ( ) <nl> + { <nl> + return " Arrows should be faded " ; <nl> + } <nl> <nl> void ParticleTestScene : : runThisTest ( ) <nl> { <nl> mmm a / tests / tests / ParticleTest / ParticleTest . h <nl> ppp b / tests / tests / ParticleTest / ParticleTest . h <nl> class ReorderParticleSystems : public ParticleDemo <nl> CCParticleBatchNode * m_pBatchNode ; <nl> } ; <nl> <nl> + class PremultipliedAlphaTest : public ParticleDemo <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + virtual std : : string title ( ) ; <nl> + virtual std : : string subtitle ( ) ; <nl> + } ; <nl> + <nl> + class PremultipliedAlphaTest2 : public ParticleDemo <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + virtual std : : string title ( ) ; <nl> + virtual std : : string subtitle ( ) ; <nl> + } ; <nl> + <nl> # endif <nl> | Merge pull request from dumganhar / gles20 | cocos2d/cocos2d-x | ea99de351a6605c697589118818d3dac40fa5696 | 2012-06-12T07:41:21Z |
mmm a / libraries / fc <nl> ppp b / libraries / fc <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 5b615cdac4ef098b3400431f4ce0639b01233a01 <nl> + Subproject commit 0e612ff8fc43c7be6aa3af321ea0ebab8da6cc31 <nl> | Update fc to version with reflector_init for derived types fix | EOSIO/eos | 2d2f5a963656f9c667a5a14844ed6dc91253719c | 2019-02-20T16:28:45Z |
mmm a / src / builtins / arm / builtins - arm . cc <nl> ppp b / src / builtins / arm / builtins - arm . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects r0 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ add ( r0 , r0 , Operand ( num_extra_args + 1 ) ) ; <nl> + __ add ( r0 , r0 , Operand ( BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ) ; <nl> <nl> / / Insert extra arguments . <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ SmiTag ( r0 ) ; <nl> __ Push ( r0 , r1 , r3 ) ; <nl> __ SmiUntag ( r0 ) ; <nl> mmm a / src / builtins / arm64 / builtins - arm64 . cc <nl> ppp b / src / builtins / arm64 / builtins - arm64 . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects x0 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ Add ( x0 , x0 , num_extra_args + 1 ) ; <nl> + __ Add ( x0 , x0 , BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ; <nl> <nl> / / Insert extra arguments . <nl> - __ SmiTag ( x0 ) ; <nl> - __ Push ( x0 , x1 , x3 ) ; <nl> - __ SmiUntag ( x0 ) ; <nl> + Register padding = x10 ; <nl> + __ LoadRoot ( padding , Heap : : kTheHoleValueRootIndex ) ; <nl> + __ SmiTag ( x11 , x0 ) ; <nl> + __ Push ( padding , x11 , x1 , x3 ) ; <nl> <nl> / / Jump to the C entry runtime stub directly here instead of using <nl> / / JumpToExternalReference . We have already loaded entry point to x5 <nl> / / in Generate_adaptor . <nl> - __ mov ( x1 , x5 ) ; <nl> + __ Mov ( x1 , x5 ) ; <nl> CEntryStub stub ( masm - > isolate ( ) , 1 , kDontSaveFPRegs , kArgvOnStack , <nl> exit_frame_type = = Builtins : : BUILTIN_EXIT ) ; <nl> __ Jump ( stub . GetCode ( ) , RelocInfo : : CODE_TARGET ) ; <nl> mmm a / src / builtins / builtins - api . cc <nl> ppp b / src / builtins / builtins - api . cc <nl> MaybeHandle < Object > Builtins : : InvokeApiFunction ( Isolate * isolate , <nl> for ( int i = 0 ; i < argc ; + + i ) { <nl> argv [ cursor - - ] = * args [ i ] ; <nl> } <nl> - DCHECK ( cursor = = BuiltinArguments : : kArgcOffset ) ; <nl> + DCHECK ( cursor = = BuiltinArguments : : kPaddingOffset ) ; <nl> + argv [ BuiltinArguments : : kPaddingOffset ] = isolate - > heap ( ) - > the_hole_value ( ) ; <nl> argv [ BuiltinArguments : : kArgcOffset ] = Smi : : FromInt ( frame_argc ) ; <nl> argv [ BuiltinArguments : : kTargetOffset ] = * function ; <nl> argv [ BuiltinArguments : : kNewTargetOffset ] = * new_target ; <nl> mmm a / src / builtins / builtins - utils . h <nl> ppp b / src / builtins / builtins - utils . h <nl> class BuiltinArguments : public Arguments { <nl> static const int kNewTargetOffset = 0 ; <nl> static const int kTargetOffset = 1 ; <nl> static const int kArgcOffset = 2 ; <nl> - static const int kNumExtraArgs = 3 ; <nl> - static const int kNumExtraArgsWithReceiver = 4 ; <nl> + static const int kPaddingOffset = 3 ; <nl> + <nl> + static const int kNumExtraArgs = 4 ; <nl> + static const int kNumExtraArgsWithReceiver = 5 ; <nl> <nl> Handle < JSFunction > target ( ) { <nl> return Arguments : : at < JSFunction > ( Arguments : : length ( ) - 1 - kTargetOffset ) ; <nl> mmm a / src / builtins / ia32 / builtins - ia32 . cc <nl> ppp b / src / builtins / ia32 / builtins - ia32 . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects eax to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ add ( eax , Immediate ( num_extra_args + 1 ) ) ; <nl> + __ add ( eax , Immediate ( BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ) ; <nl> <nl> / / Insert extra arguments . <nl> __ PopReturnAddressTo ( ecx ) ; <nl> __ SmiTag ( eax ) ; <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ Push ( eax ) ; <nl> __ SmiUntag ( eax ) ; <nl> __ Push ( edi ) ; <nl> mmm a / src / builtins / mips / builtins - mips . cc <nl> ppp b / src / builtins / mips / builtins - mips . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects a0 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ Addu ( a0 , a0 , num_extra_args + 1 ) ; <nl> + __ Addu ( a0 , a0 , BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ; <nl> <nl> / / Insert extra arguments . <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ SmiTag ( a0 ) ; <nl> __ Push ( a0 , a1 , a3 ) ; <nl> __ SmiUntag ( a0 ) ; <nl> mmm a / src / builtins / mips64 / builtins - mips64 . cc <nl> ppp b / src / builtins / mips64 / builtins - mips64 . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects a0 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ Daddu ( a0 , a0 , num_extra_args + 1 ) ; <nl> + __ Daddu ( a0 , a0 , BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ; <nl> <nl> / / Insert extra arguments . <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ SmiTag ( a0 ) ; <nl> __ Push ( a0 , a1 , a3 ) ; <nl> __ SmiUntag ( a0 ) ; <nl> mmm a / src / builtins / ppc / builtins - ppc . cc <nl> ppp b / src / builtins / ppc / builtins - ppc . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects r3 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ addi ( r3 , r3 , Operand ( num_extra_args + 1 ) ) ; <nl> + __ addi ( r3 , r3 , <nl> + Operand ( BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ) ; <nl> <nl> / / Insert extra arguments . <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ SmiTag ( r3 ) ; <nl> __ Push ( r3 , r4 , r6 ) ; <nl> __ SmiUntag ( r3 ) ; <nl> mmm a / src / builtins / s390 / builtins - s390 . cc <nl> ppp b / src / builtins / s390 / builtins - s390 . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects r2 to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ AddP ( r2 , r2 , Operand ( num_extra_args + 1 ) ) ; <nl> + __ AddP ( r2 , r2 , <nl> + Operand ( BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ) ; <nl> <nl> / / Insert extra arguments . <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ SmiTag ( r2 ) ; <nl> __ Push ( r2 , r3 , r5 ) ; <nl> __ SmiUntag ( r2 ) ; <nl> mmm a / src / builtins / x64 / builtins - x64 . cc <nl> ppp b / src / builtins / x64 / builtins - x64 . cc <nl> void AdaptorWithExitFrameType ( MacroAssembler * masm , <nl> <nl> / / CEntryStub expects rax to contain the number of arguments including the <nl> / / receiver and the extra arguments . <nl> - const int num_extra_args = 3 ; <nl> - __ addp ( rax , Immediate ( num_extra_args + 1 ) ) ; <nl> + __ addp ( rax , Immediate ( BuiltinExitFrameConstants : : kNumExtraArgsWithReceiver ) ) ; <nl> <nl> / / Unconditionally insert argc , target and new target as extra arguments . They <nl> / / will be used by stack frame iterators when constructing the stack trace . <nl> __ PopReturnAddressTo ( kScratchRegister ) ; <nl> __ Integer32ToSmi ( rax , rax ) ; <nl> + __ PushRoot ( Heap : : kTheHoleValueRootIndex ) ; / / Padding . <nl> __ Push ( rax ) ; <nl> __ SmiToInteger32 ( rax , rax ) ; <nl> __ Push ( rdi ) ; <nl> mmm a / src / compiler / js - builtin - reducer . cc <nl> ppp b / src / compiler / js - builtin - reducer . cc <nl> Reduction JSBuiltinReducer : : ReduceArrayShift ( Node * node ) { <nl> Node * argc = <nl> jsgraph ( ) - > Constant ( BuiltinArguments : : kNumExtraArgsWithReceiver ) ; <nl> if_false1 = efalse1 = vfalse1 = <nl> - graph ( ) - > NewNode ( common ( ) - > Call ( desc ) , stub_code , receiver , argc , <nl> - target , jsgraph ( ) - > UndefinedConstant ( ) , entry , <nl> - argc , context , frame_state , efalse1 , if_false1 ) ; <nl> + graph ( ) - > NewNode ( common ( ) - > Call ( desc ) , stub_code , receiver , <nl> + jsgraph ( ) - > PaddingConstant ( ) , argc , target , <nl> + jsgraph ( ) - > UndefinedConstant ( ) , entry , argc , <nl> + context , frame_state , efalse1 , if_false1 ) ; <nl> } <nl> <nl> if_false0 = graph ( ) - > NewNode ( common ( ) - > Merge ( 2 ) , if_true1 , if_false1 ) ; <nl> mmm a / src / compiler / js - graph . h <nl> ppp b / src / compiler / js - graph . h <nl> class V8_EXPORT_PRIVATE JSGraph : public NON_EXPORTED_BASE ( ZoneObject ) { <nl> Node * NaNConstant ( ) ; <nl> Node * MinusOneConstant ( ) ; <nl> <nl> + / / Used for padding frames . <nl> + Node * PaddingConstant ( ) { return TheHoleConstant ( ) ; } <nl> + <nl> / / Creates a HeapConstant node , possibly canonicalized , and may access the <nl> / / heap to inspect the object . <nl> Node * HeapConstant ( Handle < HeapObject > value ) ; <nl> mmm a / src / compiler / js - typed - lowering . cc <nl> ppp b / src / compiler / js - typed - lowering . cc <nl> void ReduceBuiltin ( Isolate * isolate , JSGraph * jsgraph , Node * node , <nl> <nl> static const int kStubAndReceiver = 2 ; <nl> int cursor = arity + kStubAndReceiver ; <nl> + node - > InsertInput ( zone , cursor + + , jsgraph - > PaddingConstant ( ) ) ; <nl> node - > InsertInput ( zone , cursor + + , argc_node ) ; <nl> node - > InsertInput ( zone , cursor + + , target ) ; <nl> node - > InsertInput ( zone , cursor + + , new_target ) ; <nl> mmm a / src / frame - constants . h <nl> ppp b / src / frame - constants . h <nl> class BuiltinExitFrameConstants : public CommonFrameConstants { <nl> static const int kNewTargetOffset = kCallerPCOffset + 1 * kPointerSize ; <nl> static const int kTargetOffset = kNewTargetOffset + 1 * kPointerSize ; <nl> static const int kArgcOffset = kTargetOffset + 1 * kPointerSize ; <nl> + static const int kPaddingOffset = kArgcOffset + 1 * kPointerSize ; <nl> + static const int kFirstArgumentOffset = kPaddingOffset + 1 * kPointerSize ; <nl> + static const int kNumExtraArgsWithReceiver = 5 ; <nl> } ; <nl> <nl> class InterpreterFrameConstants : public AllStatic { <nl> mmm a / src / frames . cc <nl> ppp b / src / frames . cc <nl> bool BuiltinExitFrame : : IsConstructor ( ) const { <nl> <nl> Object * BuiltinExitFrame : : GetParameter ( int i ) const { <nl> DCHECK ( i > = 0 & & i < ComputeParametersCount ( ) ) ; <nl> - int offset = BuiltinExitFrameConstants : : kArgcOffset + ( i + 1 ) * kPointerSize ; <nl> + int offset = <nl> + BuiltinExitFrameConstants : : kFirstArgumentOffset + i * kPointerSize ; <nl> return Memory : : Object_at ( fp ( ) + offset ) ; <nl> } <nl> <nl> | Add padding to builtin exit frames . | v8/v8 | 57ea01af617c92a53fbe3fddf0b76b38b6a1c1fd | 2017-10-13T13:52:18Z |
mmm a / src / video_core / engines / maxwell_3d . h <nl> ppp b / src / video_core / engines / maxwell_3d . h <nl> class Maxwell3D final { <nl> u32 enable [ NumRenderTargets ] ; <nl> } blend ; <nl> <nl> - INSERT_PADDING_WORDS ( 0x77 ) ; <nl> + INSERT_PADDING_WORDS ( 0x2D ) ; <nl> + <nl> + u32 vb_element_base ; <nl> + <nl> + INSERT_PADDING_WORDS ( 0x49 ) ; <nl> <nl> struct { <nl> u32 tsc_address_high ; <nl> ASSERT_REG_POSITION ( vertex_attrib_format [ 0 ] , 0x458 ) ; <nl> ASSERT_REG_POSITION ( rt_control , 0x487 ) ; <nl> ASSERT_REG_POSITION ( independent_blend_enable , 0x4B9 ) ; <nl> ASSERT_REG_POSITION ( blend , 0x4CF ) ; <nl> + ASSERT_REG_POSITION ( vb_element_base , 0x50D ) ; <nl> ASSERT_REG_POSITION ( tsc , 0x557 ) ; <nl> ASSERT_REG_POSITION ( tic , 0x55D ) ; <nl> ASSERT_REG_POSITION ( code_address , 0x582 ) ; <nl> | GPU : Added register definitions for the vertex buffer base element . | yuzu-emu/yuzu | cc73bad293cadb2323a821fa32bcd03c9d359e3e | 2018-07-02T16:21:23Z |
mmm a / . gitignore <nl> ppp b / . gitignore <nl> shell_g <nl> / test / test262 / data <nl> / test / test262 / data . old <nl> / test / test262 / tc39 - test262 - * <nl> - / test / test262 / test262 - * <nl> / third_party <nl> / tools / jsfunfuzz <nl> / tools / jsfunfuzz . zip <nl> | Drop gitignore entry for now obsolete test262 archive | v8/v8 | 6dd3cb07bf5f73cd0a3543a9a4a0d7901d6d3e68 | 2014-05-23T08:23:41Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.