mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Compare commits
490 Commits
3.4.0
..
3.4.1-cvsdk
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b15f3e3b9 | |||
| 265f335dae | |||
| e283a75a19 | |||
| ed96279920 | |||
| e79be78ef4 | |||
| 4a6d582f2e | |||
| e969f184e1 | |||
| ca9af20179 | |||
| 0f1e193193 | |||
| 6ffc48769a | |||
| 4a74408eee | |||
| c729fbd652 | |||
| 608968aa83 | |||
| 5caf6244a3 | |||
| eaaba6462e | |||
| 92e9d4ec3a | |||
| fbb2cabe77 | |||
| 3fd2384b81 | |||
| e851a41d78 | |||
| 5e0f95b948 | |||
| f7aa2e0d44 | |||
| a11b7a8293 | |||
| e6062532fa | |||
| e7d35d51fa | |||
| c524f669c7 | |||
| 203ac0f818 | |||
| eab556e1e0 | |||
| 9819ebc095 | |||
| fb6db3dcfc | |||
| 7601c21612 | |||
| cb9b08eca1 | |||
| 48b8aa51cd | |||
| 6e8241b78d | |||
| f61076a5d8 | |||
| 5f5fcef962 | |||
| 12ce6b5c15 | |||
| 27b1f8f446 | |||
| c6e1e3acdc | |||
| 53661d55ae | |||
| 120b7a61c3 | |||
| 470d34ddbb | |||
| a0c2718adb | |||
| a836892edb | |||
| 25518a12f1 | |||
| 2aa15ab3ff | |||
| 807ec00b85 | |||
| 53305d4a7e | |||
| 2863f950d6 | |||
| 12d2bd4adb | |||
| 24ee7b5080 | |||
| aab390c51d | |||
| 8b4871a28d | |||
| cf31243c74 | |||
| 88b689bcf1 | |||
| f589237e23 | |||
| 7da6e9086c | |||
| 68043f4de9 | |||
| c0eaff3608 | |||
| bcce25900b | |||
| 34ba32ff27 | |||
| 857007372d | |||
| 6a661e1e28 | |||
| cc5a6f3b86 | |||
| aa7a964139 | |||
| 73a8369631 | |||
| 6a8f57e5d7 | |||
| eb94dfb442 | |||
| 7be0c78533 | |||
| 97d9ea00fe | |||
| 491502a349 | |||
| 0e4eed0ba1 | |||
| 8ffcc76011 | |||
| c020a7bb67 | |||
| e268fdc0ed | |||
| bb925fe488 | |||
| 1dbdb1cfc9 | |||
| 30b33a4413 | |||
| 945ad277ea | |||
| 6f4e35cc0e | |||
| df8f61877e | |||
| ddb482b14a | |||
| f378f1d585 | |||
| 36f11a54e1 | |||
| f8d0d6365e | |||
| cff79609c8 | |||
| c434198ee5 | |||
| ef70b0baa4 | |||
| b4ddf3d8c5 | |||
| 42b25d747b | |||
| a66b5e2c13 | |||
| 8f0b72be9e | |||
| 15dc6f70dc | |||
| 95014f311d | |||
| 6dfd7e3da2 | |||
| cfe84b953c | |||
| f78b9468dd | |||
| 034dc3b0dd | |||
| 80d1f2ddfa | |||
| d05714995c | |||
| 252e871a8b | |||
| 59b91d6c31 | |||
| 5992c46606 | |||
| 00d2f34888 | |||
| a91a11e533 | |||
| 2423cddb00 | |||
| eb54e5c55c | |||
| 514e6df460 | |||
| 94253e8b83 | |||
| a6baedd02c | |||
| c63092781a | |||
| 2d1350a9d6 | |||
| 2200e13c71 | |||
| 633b0e56a5 | |||
| 8393d755f6 | |||
| 7474ad81d9 | |||
| e805a55a5b | |||
| 14032c6653 | |||
| 17233c687e | |||
| 57cbde3393 | |||
| 579781e35e | |||
| 66f3c1ae79 | |||
| 1ad814a191 | |||
| 221342fb25 | |||
| 5718d09e39 | |||
| b67523550f | |||
| 5a791e6e06 | |||
| 61e76e767d | |||
| 51b5fdba25 | |||
| 379ea15d16 | |||
| 4437e0c3b9 | |||
| fad3a6bf15 | |||
| ab0f0f26a1 | |||
| b7ad95beaa | |||
| 2c8da29f3a | |||
| efd3fafa25 | |||
| d61528b2d5 | |||
| e8b2c5682e | |||
| ce2a65db85 | |||
| 2f3d4df2f2 | |||
| 6205981235 | |||
| 28a78003f0 | |||
| e2a99d24ec | |||
| 601e3aaf98 | |||
| dd2fd39c05 | |||
| 84887d3011 | |||
| 9e298ea1bb | |||
| 65ba2e0adf | |||
| 42e1fe301c | |||
| 7fe97376c2 | |||
| 03407a9da0 | |||
| d56b2b56fb | |||
| d47b1f3b70 | |||
| 090ee46f4a | |||
| dbb57cd0ae | |||
| 0c07836fba | |||
| 835acd3f31 | |||
| f8b03d4a4b | |||
| 413fba14ab | |||
| 44d7435a48 | |||
| f77f2876ff | |||
| 914f57f28d | |||
| ed94136548 | |||
| c973aaabc5 | |||
| 3267fb90c6 | |||
| b10fedde56 | |||
| 8817907647 | |||
| 398ebbac98 | |||
| c43498c6ad | |||
| 389fa5d38e | |||
| 2a1f46c42d | |||
| e225850cc6 | |||
| 10e1de74d2 | |||
| 292dfc2d72 | |||
| b085158d59 | |||
| 904640c9ae | |||
| 06455fc0cd | |||
| 3b191bf2dd | |||
| 56bcdfd7d9 | |||
| 14089b1e7c | |||
| 5f6077bc62 | |||
| 19a914be16 | |||
| f1c91a8d34 | |||
| 5a71f4a0ca | |||
| a449731a57 | |||
| e801e336ed | |||
| 0d01b97b75 | |||
| 7fedfa0380 | |||
| 4a297a2443 | |||
| 108d07c655 | |||
| 34a9ce6eb3 | |||
| f1e50ecab3 | |||
| a0ce12f8ba | |||
| 3d6659112f | |||
| 1055f9d208 | |||
| 403c3c3d03 | |||
| 877b175565 | |||
| 82f889d9b8 | |||
| 7eb37bd1dd | |||
| 384fa95680 | |||
| 2266a8c85f | |||
| 83761d5f8e | |||
| ecbd5b0574 | |||
| c8d8b1fbcd | |||
| 92fb3fb33f | |||
| 02bc17be6f | |||
| 534dcbe017 | |||
| 12cd3b55ec | |||
| bbfa239036 | |||
| c96630c9f0 | |||
| 60f1c9dcdf | |||
| 82aff110b7 | |||
| 26321795f7 | |||
| f780ee12a0 | |||
| e56d6054aa | |||
| 36222c9eed | |||
| 8436dac090 | |||
| 713ec7be45 | |||
| 42569cfd61 | |||
| 7c8a3da0ac | |||
| 9d25bd583f | |||
| 85af8735ab | |||
| ccea0a831a | |||
| 65a6674c6e | |||
| 9698b93d10 | |||
| 78ce5b815d | |||
| 6aec71d7ee | |||
| 83b16ab7b7 | |||
| 54c81cbde4 | |||
| 3cf535926a | |||
| 35738bcadd | |||
| 184862582c | |||
| c4f9ff0285 | |||
| a75840d19c | |||
| f06c44f1f1 | |||
| 844f1d0281 | |||
| a2e9bfbaf4 | |||
| 2e45095e8d | |||
| 027da35c33 | |||
| 2c1161a6f9 | |||
| 5f4b48da34 | |||
| 4e1d396ce1 | |||
| 98bd0a06dc | |||
| f57630d92b | |||
| ae2e4af4a1 | |||
| cb66f82c1d | |||
| 1389fd67ab | |||
| 7a4c5e9421 | |||
| cf1ba0c4e1 | |||
| ebdb0eb0c1 | |||
| 4d80419f29 | |||
| 32d71cf85f | |||
| 2876670de3 | |||
| 36d4c29b11 | |||
| c8930cc279 | |||
| 01f4a173ab | |||
| daf3368d2e | |||
| f6fd3abd31 | |||
| f1c52e426b | |||
| 203dc3bb48 | |||
| 7b8ab4e5c6 | |||
| 73891d619a | |||
| fe4fbc2c3b | |||
| 2ebf4e084a | |||
| df22bafe6d | |||
| c49d5d5252 | |||
| 104502c5be | |||
| 7d6cf66303 | |||
| d1b08486ae | |||
| 205022ceee | |||
| 47998c03f8 | |||
| 27cddfb8e9 | |||
| 3f116468c6 | |||
| 8c2563be41 | |||
| 2493083935 | |||
| e15928b49e | |||
| df434298b8 | |||
| c401168bea | |||
| 0b1f626efd | |||
| 74367093c8 | |||
| 7a472d85ef | |||
| 81c5fae56f | |||
| 9e9926a2f0 | |||
| 6e5da9dbe3 | |||
| b97b650ab3 | |||
| a1d2258ac3 | |||
| 8f04c8b16c | |||
| 2d674fc151 | |||
| 479179638e | |||
| a3d74704e5 | |||
| 90aac764dd | |||
| 46470d92a0 | |||
| a5cd62f7bf | |||
| 12ea8477a3 | |||
| 87db636c61 | |||
| c5c620bab0 | |||
| d84c7e5143 | |||
| 8ba88892d7 | |||
| eb2901bd69 | |||
| c89ae6e537 | |||
| 25c36fb05f | |||
| 71ba54b2f4 | |||
| 18ce529256 | |||
| 26e0f408f0 | |||
| fe494297e4 | |||
| c3569211d5 | |||
| dcc5a2cb22 | |||
| 67842df9e2 | |||
| 8226bd25c4 | |||
| 8efe7bafaa | |||
| 2124361ff7 | |||
| 42459cad02 | |||
| 0def2dbb73 | |||
| 1b0ff57562 | |||
| 95ce21d407 | |||
| ec353dbdda | |||
| f056e713c3 | |||
| 4046d9f850 | |||
| aa55cdb735 | |||
| ec8d39d059 | |||
| d1a3b530be | |||
| a55aed5f42 | |||
| b067e0ca5d | |||
| 85e133a051 | |||
| 4a086cf517 | |||
| fb22028be3 | |||
| 6728b40ad3 | |||
| e77af4ae33 | |||
| 7bc017601f | |||
| decf6cab5e | |||
| 2b635edce6 | |||
| 2aa18ca3e9 | |||
| 4dc788ff84 | |||
| cec700525c | |||
| 20b3261204 | |||
| ab8cf31ae9 | |||
| c0ae812aa2 | |||
| 8b87c4b96a | |||
| cbb21f3cf2 | |||
| 4189214d04 | |||
| e6ed853905 | |||
| 59915a3fc9 | |||
| 22816a4c43 | |||
| 4d84999452 | |||
| 6d4b778303 | |||
| df0b83332d | |||
| be1207e5e4 | |||
| 1255bd8d4b | |||
| f5d9a2a9c1 | |||
| edcbbee979 | |||
| 70ff4af4fa | |||
| 6a395d88ff | |||
| 1f4fdfd599 | |||
| 0c00652f6b | |||
| 91e10a3105 | |||
| 08086178bd | |||
| 839cffdefe | |||
| a362fd80df | |||
| 1237faef80 | |||
| a0d9d6db5b | |||
| 8533b45ce9 | |||
| dcd4f8f5db | |||
| 0cad2d2a83 | |||
| 73316e10a0 | |||
| 69cd9cc1a6 | |||
| 594a93316c | |||
| c6d9ce8fd3 | |||
| 9deaddcdff | |||
| 98b6e1d5fe | |||
| 57dc28fe99 | |||
| c8794c89c7 | |||
| 18edd917e3 | |||
| 6032d86e23 | |||
| 64a9e92390 | |||
| b6075e11b8 | |||
| c19764e557 | |||
| 71768de939 | |||
| f943261847 | |||
| 7763b58a60 | |||
| 6f8be3f693 | |||
| 6113dc1b99 | |||
| 4d4f291553 | |||
| 29faf164b9 | |||
| 435a3e337b | |||
| f92e880d3d | |||
| 8a76fadaa3 | |||
| be5247921d | |||
| e3b42bf93b | |||
| f34a0a874a | |||
| c71dc78cd4 | |||
| f3dde79ed6 | |||
| da0904df2d | |||
| c08a0edea1 | |||
| 27b55ea761 | |||
| 8943441115 | |||
| 6674a024fc | |||
| ee35263e48 | |||
| 84596bff09 | |||
| e3a6d74945 | |||
| dd3c1d3b8c | |||
| 3a5cd12dee | |||
| 2d2499f610 | |||
| c11895f529 | |||
| 004a1cd64a | |||
| d0b2e60edc | |||
| 8e1f31f543 | |||
| a2869109f0 | |||
| 431b3b4323 | |||
| 9966903ae1 | |||
| 8a67858068 | |||
| f5862dacb6 | |||
| 67f9406cbe | |||
| f99a135eda | |||
| e1ec45c948 | |||
| 8acd05f12a | |||
| be01ea734d | |||
| d01a2038ae | |||
| 0e6dd32858 | |||
| bc7923e382 | |||
| c608c232a2 | |||
| 5f9bb6249e | |||
| b76a691bcf | |||
| bc6a355370 | |||
| 37911e60d8 | |||
| c92aa95726 | |||
| 59c6661db0 | |||
| f0453bd853 | |||
| 116c8d0ddf | |||
| 16821b877c | |||
| 45c5f0a549 | |||
| f46eff4eb0 | |||
| 1073175c77 | |||
| 34bfd7ef51 | |||
| 94b236872c | |||
| 7abaae39ec | |||
| 940a90130d | |||
| a42ca2eeb3 | |||
| bf80c94125 | |||
| d0580df339 | |||
| ea5a3e557f | |||
| 22576f4dfe | |||
| 4ca89db22d | |||
| dc88a2bcf2 | |||
| 71f4281080 | |||
| 4bd1e3dcbd | |||
| 30373d2566 | |||
| 914d9662d3 | |||
| ad23c10600 | |||
| a50a355e63 | |||
| 7d67d60fb1 | |||
| fc1d85bf59 | |||
| 125f9f0be1 | |||
| 8e7af7f089 | |||
| a65b5df5da | |||
| 2370c8a058 | |||
| 2b3c140f04 | |||
| ec32022bdf | |||
| 898ca38257 | |||
| 5aac909046 | |||
| 592f8d8c1b | |||
| a9807d8f54 | |||
| d9c0231475 | |||
| f0b606ff77 | |||
| 3542c98d45 | |||
| 00f03c5739 | |||
| 4f6c493b87 | |||
| 73c2a12449 | |||
| 99a9c10b57 | |||
| 9b131b5f7e | |||
| 5232ea1ee6 | |||
| d8d4ea857a | |||
| f3880c60a6 | |||
| 6045608330 | |||
| 0a4b1b8d68 | |||
| 25c17b107e | |||
| 2938860b3f | |||
| 2e33844f0d | |||
| 1e4395a8e1 | |||
| 70c605a03d | |||
| 84e2fa79a0 | |||
| a8844de7b5 | |||
| 0369431ebd | |||
| 50e8f91064 | |||
| fd0ac962fb | |||
| fc8e848a54 | |||
| 26d288bd11 | |||
| adf43e7d2a | |||
| 047764f476 | |||
| cd1c8693d8 | |||
| 602b08d9c7 | |||
| 235889ddbb |
@@ -1,2 +0,0 @@
|
|||||||
[tgit]
|
|
||||||
icon = doc/opencv.ico
|
|
||||||
Vendored
+2
@@ -31,3 +31,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(cpufeatures LICENSE README.md)
|
||||||
|
|||||||
Vendored
+6
-6
@@ -1,9 +1,9 @@
|
|||||||
# Binary branch name: ffmpeg/master_20171009
|
# Binaries branch name: ffmpeg/master_20180220
|
||||||
# Binaries were created for OpenCV: 8ac2c5d620b467d3f22802e96c88ddde6da707af
|
# Binaries were created for OpenCV: 9819ebc0954c2df62943ebbd5936d325e5dc89e1
|
||||||
set(FFMPEG_BINARIES_COMMIT "66b1fed06cf3510235f367f96aa26da5cb234a15")
|
ocv_update(FFMPEG_BINARIES_COMMIT "0a0e88972a7ea97708378d0488a65f83e7cc5e69")
|
||||||
set(FFMPEG_FILE_HASH_BIN32 "3ae76b105113d944984b2351c61e21c6")
|
ocv_update(FFMPEG_FILE_HASH_BIN32 "b8120c07962d591e2e9071a1bf566fd0")
|
||||||
set(FFMPEG_FILE_HASH_BIN64 "cf3bb5bc9d393b022ea7a42eb63e794d")
|
ocv_update(FFMPEG_FILE_HASH_BIN64 "dc9c50e7b05482acc25d6ce0ac61bf1d")
|
||||||
set(FFMPEG_FILE_HASH_CMAKE "ec59008da403fb18ab3c1ed66aed583b")
|
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
|
||||||
|
|
||||||
function(download_win_ffmpeg script_var)
|
function(download_win_ffmpeg script_var)
|
||||||
set(${script_var} "" PARENT_SCOPE)
|
set(${script_var} "" PARENT_SCOPE)
|
||||||
|
|||||||
Vendored
+25
@@ -0,0 +1,25 @@
|
|||||||
|
Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and/or associated documentation files (the
|
||||||
|
"Materials"), to deal in the Materials without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Materials, and to
|
||||||
|
permit persons to whom the Materials are furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Materials.
|
||||||
|
|
||||||
|
MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
|
||||||
|
KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
|
||||||
|
SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
|
||||||
|
https://www.khronos.org/registry/
|
||||||
|
|
||||||
|
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||||
Vendored
+2
@@ -60,3 +60,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(ittnotify src/ittnotify/LICENSE.BSD src/ittnotify/LICENSE.GPL)
|
||||||
|
|||||||
Vendored
+2
@@ -47,3 +47,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(jasper LICENSE README copyright)
|
||||||
|
|||||||
Vendored
+2
@@ -51,3 +51,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(libjpeg README)
|
||||||
|
|||||||
Vendored
+3
-1
@@ -48,7 +48,7 @@ if(PPC64LE OR PPC64)
|
|||||||
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
|
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
|
||||||
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -80,3 +80,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(libpng LICENSE README opencv-libpng.patch)
|
||||||
|
|||||||
Vendored
+10
-4
@@ -244,10 +244,14 @@ mark_as_advanced(HAVE_IEEEFP)
|
|||||||
|
|
||||||
# Large file support
|
# Large file support
|
||||||
if(UNIX OR MINGW)
|
if(UNIX OR MINGW)
|
||||||
# This might not catch every possibility catered for by
|
if(ANDROID AND (ANDROID_NATIVE_API_LEVEL LESS 21) AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang))
|
||||||
# AC_SYS_LARGEFILE.
|
# Android NDK build problem: 'mmap' issue with GCC and API<21
|
||||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
else()
|
||||||
set(FILE_OFFSET_BITS 64)
|
# This might not catch every possibility catered for by
|
||||||
|
# AC_SYS_LARGEFILE.
|
||||||
|
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||||
|
set(FILE_OFFSET_BITS 64)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Documentation install directory (default to cmake project docdir)
|
# Documentation install directory (default to cmake project docdir)
|
||||||
@@ -466,3 +470,5 @@ endif()
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(libtiff COPYRIGHT)
|
||||||
|
|||||||
-3
@@ -245,9 +245,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
|
||||||
#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@
|
|
||||||
|
|
||||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
|
|||||||
Vendored
+2
@@ -76,5 +76,7 @@ if(NOT BUILD_SHARED_LIBS)
|
|||||||
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(openexr LICENSE AUTHORS.ilmbase AUTHORS.openexr fix_msvc2013_errors.patch)
|
||||||
|
|
||||||
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)
|
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)
|
||||||
set(OPENEXR_VERSION "1.7.1" PARENT_SCOPE)
|
set(OPENEXR_VERSION "1.7.1" PARENT_SCOPE)
|
||||||
|
|||||||
Vendored
+15
-4
@@ -1,5 +1,4 @@
|
|||||||
project(libprotobuf)
|
project(libprotobuf)
|
||||||
|
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
|
|
||||||
if(HAVE_PTHREAD)
|
if(HAVE_PTHREAD)
|
||||||
@@ -11,12 +10,16 @@ if(MSVC)
|
|||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
|
||||||
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
|
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
|
||||||
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
|
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
|
||||||
|
/wd4701 /wd4703 # potentially uninitialized local/pointer variable 'value' used
|
||||||
|
/wd4505 # unreferenced local function has been removed
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
|
#NOTE: -Wno-invalid-offsetof was used as solution for invalid offset warning on protobuf #3450
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
|
||||||
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
|
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
|
||||||
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
|
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
|
||||||
-Wunused-function -Wunused-const-variable -Wshorten-64-to-32
|
-Wunused-function -Wunused-const-variable -Wshorten-64-to-32 -Wno-invalid-offsetof
|
||||||
|
-Wenum-compare-switch
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(CV_ICC)
|
if(CV_ICC)
|
||||||
@@ -52,6 +55,7 @@ append_if_exist(Protobuf_SRCS
|
|||||||
${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
|
||||||
|
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_table_driven_lite.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
|
||||||
@@ -62,6 +66,7 @@ append_if_exist(Protobuf_SRCS
|
|||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
|
||||||
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/io_win32.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
|
||||||
@@ -86,6 +91,7 @@ append_if_exist(Protobuf_SRCS
|
|||||||
${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
|
||||||
|
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_table_driven.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
|
||||||
@@ -103,6 +109,7 @@ append_if_exist(Protobuf_SRCS
|
|||||||
${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
|
||||||
|
${PROTOBUF_ROOT}/src/google/protobuf/util/delimited_message_util.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
|
||||||
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
|
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
|
||||||
@@ -128,8 +135,7 @@ append_if_exist(Protobuf_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(libprotobuf STATIC ${Protobuf_SRCS})
|
add_library(libprotobuf STATIC ${Protobuf_SRCS})
|
||||||
ocv_include_directories(${PROTOBUF_ROOT}/src)
|
target_include_directories(libprotobuf SYSTEM PUBLIC $<BUILD_INTERFACE:${PROTOBUF_ROOT}/src>)
|
||||||
|
|
||||||
set_target_properties(libprotobuf
|
set_target_properties(libprotobuf
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
FOLDER "3rdparty"
|
FOLDER "3rdparty"
|
||||||
@@ -138,6 +144,11 @@ set_target_properties(libprotobuf
|
|||||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
get_protobuf_version(Protobuf_VERSION "${PROTOBUF_ROOT}/src")
|
||||||
|
set(Protobuf_VERSION ${Protobuf_VERSION} CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_3rdparty_licenses(protobuf LICENSE README.md)
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
Project: Protocol Buffers - Google's data interchange format
|
Project: Protocol Buffers - Google's data interchange format
|
||||||
Source code: https://github.com/google/protobuf
|
Source code: https://github.com/google/protobuf
|
||||||
Version: 3.1.0
|
Version: 3.5.1
|
||||||
|
|||||||
+4
-4
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <google/protobuf/any.h>
|
#include <google/protobuf/any.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/generated_message_util.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -70,13 +72,11 @@ bool AnyMetadata::UnpackTo(Message* message) const {
|
|||||||
if (!InternalIs(message->GetDescriptor())) {
|
if (!InternalIs(message->GetDescriptor())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return message->ParseFromString(
|
return message->ParseFromString(value_->GetNoArena());
|
||||||
value_->GetNoArena(&::google::protobuf::internal::GetEmptyString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnyMetadata::InternalIs(const Descriptor* descriptor) const {
|
bool AnyMetadata::InternalIs(const Descriptor* descriptor) const {
|
||||||
const string type_url = type_url_->GetNoArena(
|
const string type_url = type_url_->GetNoArena();
|
||||||
&::google::protobuf::internal::GetEmptyString());
|
|
||||||
string full_name;
|
string full_name;
|
||||||
if (!ParseAnyTypeUrl(type_url, &full_name)) {
|
if (!ParseAnyTypeUrl(type_url, &full_name)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-3
@@ -63,7 +63,7 @@ class LIBPROTOBUF_EXPORT AnyMetadata {
|
|||||||
|
|
||||||
// Unpacks the payload into the given message. Returns false if the message's
|
// Unpacks the payload into the given message. Returns false if the message's
|
||||||
// type doesn't match the type specified in the type URL (i.e., the full
|
// type doesn't match the type specified in the type URL (i.e., the full
|
||||||
// name after the last "/" of the type URL doesn't match the message's actaul
|
// name after the last "/" of the type URL doesn't match the message's actual
|
||||||
// full name) or parsing the payload has failed.
|
// full name) or parsing the payload has failed.
|
||||||
bool UnpackTo(Message* message) const;
|
bool UnpackTo(Message* message) const;
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@ extern const char kTypeGoogleProdComPrefix[]; // "type.googleprod.com/".
|
|||||||
|
|
||||||
// Get the proto type name from Any::type_url value. For example, passing
|
// Get the proto type name from Any::type_url value. For example, passing
|
||||||
// "type.googleapis.com/rpc.QueryOrigin" will return "rpc.QueryOrigin" in
|
// "type.googleapis.com/rpc.QueryOrigin" will return "rpc.QueryOrigin" in
|
||||||
// *full_type_name. Returns false if type_url does not start with
|
// *full_type_name. Returns false if the type_url does not have a "/"
|
||||||
// "type.googleapis.com" or "type.googleprod.com".
|
// in the type url separating the full type name.
|
||||||
bool ParseAnyTypeUrl(const string& type_url, string* full_type_name);
|
bool ParseAnyTypeUrl(const string& type_url, string* full_type_name);
|
||||||
|
|
||||||
// See if message is of type google.protobuf.Any, if so, return the descriptors
|
// See if message is of type google.protobuf.Any, if so, return the descriptors
|
||||||
|
|||||||
+173
-256
@@ -1,7 +1,6 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: google/protobuf/any.proto
|
// source: google/protobuf/any.proto
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include <google/protobuf/any.pb.h>
|
#include <google/protobuf/any.pb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -15,119 +14,114 @@
|
|||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
|
// This is a temporary google only hack
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
#include "third_party/protobuf/version.h"
|
||||||
|
#endif
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
class AnyDefaultTypeInternal {
|
||||||
|
public:
|
||||||
|
::google::protobuf::internal::ExplicitlyConstructed<Any>
|
||||||
|
_instance;
|
||||||
|
} _Any_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace protobuf_google_2fprotobuf_2fany_2eproto {
|
||||||
|
void InitDefaultsAnyImpl() {
|
||||||
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
|
||||||
|
#else
|
||||||
|
::google::protobuf::internal::InitProtobufDefaults();
|
||||||
|
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
{
|
||||||
|
void* ptr = &::google::protobuf::_Any_default_instance_;
|
||||||
|
new (ptr) ::google::protobuf::Any();
|
||||||
|
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
||||||
|
}
|
||||||
|
::google::protobuf::Any::InitAsDefaultInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDefaultsAny() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsAnyImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
::google::protobuf::Metadata file_level_metadata[1];
|
||||||
|
|
||||||
|
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
~0u, // no _has_bits_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, _internal_metadata_),
|
||||||
|
~0u, // no _extensions_
|
||||||
|
~0u, // no _oneof_case_
|
||||||
|
~0u, // no _weak_field_map_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, type_url_),
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Any, value_),
|
||||||
|
};
|
||||||
|
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
{ 0, -1, sizeof(::google::protobuf::Any)},
|
||||||
|
};
|
||||||
|
|
||||||
|
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||||
|
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Any_default_instance_),
|
||||||
|
};
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptors() {
|
||||||
|
AddDescriptors();
|
||||||
|
::google::protobuf::MessageFactory* factory = NULL;
|
||||||
|
AssignDescriptors(
|
||||||
|
"google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||||
|
file_level_metadata, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptorsOnce() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) {
|
||||||
|
protobuf_AssignDescriptorsOnce();
|
||||||
|
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptorsImpl() {
|
||||||
|
InitDefaults();
|
||||||
|
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
"\n\031google/protobuf/any.proto\022\017google.prot"
|
||||||
|
"obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
|
||||||
|
" \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z"
|
||||||
|
"%github.com/golang/protobuf/ptypes/any\242\002"
|
||||||
|
"\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p"
|
||||||
|
"roto3"
|
||||||
|
};
|
||||||
|
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||||
|
descriptor, 205);
|
||||||
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
|
"google/protobuf/any.proto", &protobuf_RegisterTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptors() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||||
|
}
|
||||||
|
// Force AddDescriptors() to be called at dynamic initialization time.
|
||||||
|
struct StaticDescriptorInitializer {
|
||||||
|
StaticDescriptorInitializer() {
|
||||||
|
AddDescriptors();
|
||||||
|
}
|
||||||
|
} static_descriptor_initializer;
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fany_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* Any_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
Any_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"google/protobuf/any.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
Any_descriptor_ = file->message_type(0);
|
|
||||||
static const int Any_offsets_[2] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
|
|
||||||
};
|
|
||||||
Any_reflection_ =
|
|
||||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
|
||||||
Any_descriptor_,
|
|
||||||
Any::internal_default_instance(),
|
|
||||||
Any_offsets_,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
sizeof(Any),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
Any_descriptor_, Any::internal_default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() {
|
|
||||||
Any_default_instance_.Shutdown();
|
|
||||||
delete Any_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
::google::protobuf::internal::GetEmptyString();
|
|
||||||
Any_default_instance_.DefaultConstruct();
|
|
||||||
Any_default_instance_.get_mutable()->InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_);
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_,
|
|
||||||
&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl);
|
|
||||||
}
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n\031google/protobuf/any.proto\022\017google.prot"
|
|
||||||
"obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
|
|
||||||
" \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z"
|
|
||||||
"%github.com/golang/protobuf/ptypes/any\242\002"
|
|
||||||
"\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p"
|
|
||||||
"roto3", 205);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"google/protobuf/any.proto", &protobuf_RegisterTypes);
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_);
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_,
|
|
||||||
&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto {
|
|
||||||
StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
static void MergeFromFail(int line) {
|
|
||||||
::google::protobuf::internal::MergeFromFail(__FILE__, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
void Any::InitAsDefaultInstance() {
|
||||||
|
}
|
||||||
void Any::PackFrom(const ::google::protobuf::Message& message) {
|
void Any::PackFrom(const ::google::protobuf::Message& message) {
|
||||||
_any_metadata_.PackFrom(message);
|
_any_metadata_.PackFrom(message);
|
||||||
}
|
}
|
||||||
@@ -148,20 +142,26 @@ const int Any::kValueFieldNumber;
|
|||||||
|
|
||||||
Any::Any()
|
Any::Any()
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {
|
: ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {
|
||||||
if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||||
|
::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAny();
|
||||||
|
}
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
// @@protoc_insertion_point(constructor:google.protobuf.Any)
|
// @@protoc_insertion_point(constructor:google.protobuf.Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Any::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Any::Any(const Any& from)
|
Any::Any(const Any& from)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(NULL),
|
_internal_metadata_(NULL),
|
||||||
_any_metadata_(&type_url_, &value_) {
|
_cached_size_(0),
|
||||||
SharedCtor();
|
_any_metadata_(&type_url_, &value_) {
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
|
type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
if (from.type_url().size() > 0) {
|
||||||
|
type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);
|
||||||
|
}
|
||||||
|
value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
if (from.value().size() > 0) {
|
||||||
|
value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
|
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,17 +187,15 @@ void Any::SetCachedSize(int size) const {
|
|||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||||
}
|
}
|
||||||
const ::google::protobuf::Descriptor* Any::descriptor() {
|
const ::google::protobuf::Descriptor* Any::descriptor() {
|
||||||
protobuf_AssignDescriptorsOnce();
|
::protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
return Any_descriptor_;
|
return ::protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Any& Any::default_instance() {
|
const Any& Any::default_instance() {
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAny();
|
||||||
return *internal_default_instance();
|
return *internal_default_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_;
|
|
||||||
|
|
||||||
Any* Any::New(::google::protobuf::Arena* arena) const {
|
Any* Any::New(::google::protobuf::Arena* arena) const {
|
||||||
Any* n = new Any;
|
Any* n = new Any;
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
@@ -208,8 +206,13 @@ Any* Any::New(::google::protobuf::Arena* arena) const {
|
|||||||
|
|
||||||
void Any::Clear() {
|
void Any::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:google.protobuf.Any)
|
// @@protoc_insertion_point(message_clear_start:google.protobuf.Any)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
_internal_metadata_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Any::MergePartialFromCodedStream(
|
bool Any::MergePartialFromCodedStream(
|
||||||
@@ -218,47 +221,45 @@ bool Any::MergePartialFromCodedStream(
|
|||||||
::google::protobuf::uint32 tag;
|
::google::protobuf::uint32 tag;
|
||||||
// @@protoc_insertion_point(parse_start:google.protobuf.Any)
|
// @@protoc_insertion_point(parse_start:google.protobuf.Any)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
|
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
||||||
tag = p.first;
|
tag = p.first;
|
||||||
if (!p.second) goto handle_unusual;
|
if (!p.second) goto handle_unusual;
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||||
// optional string type_url = 1;
|
// string type_url = 1;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (tag == 10) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
|
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
||||||
input, this->mutable_type_url()));
|
input, this->mutable_type_url()));
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->type_url().data(), this->type_url().length(),
|
this->type_url().data(), static_cast<int>(this->type_url().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
::google::protobuf::internal::WireFormatLite::PARSE,
|
||||||
"google.protobuf.Any.type_url"));
|
"google.protobuf.Any.type_url"));
|
||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectTag(18)) goto parse_value;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
case 2: {
|
case 2: {
|
||||||
if (tag == 18) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
parse_value:
|
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
|
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
|
||||||
input, this->mutable_value()));
|
input, this->mutable_value()));
|
||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectAtEnd()) goto success;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if (tag == 0 ||
|
if (tag == 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
|
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||||
|
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,22 +276,29 @@ failure:
|
|||||||
void Any::SerializeWithCachedSizes(
|
void Any::SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
::google::protobuf::io::CodedOutputStream* output) const {
|
||||||
// @@protoc_insertion_point(serialize_start:google.protobuf.Any)
|
// @@protoc_insertion_point(serialize_start:google.protobuf.Any)
|
||||||
// optional string type_url = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// string type_url = 1;
|
||||||
if (this->type_url().size() > 0) {
|
if (this->type_url().size() > 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->type_url().data(), this->type_url().length(),
|
this->type_url().data(), static_cast<int>(this->type_url().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.Any.type_url");
|
"google.protobuf.Any.type_url");
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
|
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
|
||||||
1, this->type_url(), output);
|
1, this->type_url(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
if (this->value().size() > 0) {
|
if (this->value().size() > 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
|
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
|
||||||
2, this->value(), output);
|
2, this->value(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_end:google.protobuf.Any)
|
// @@protoc_insertion_point(serialize_end:google.protobuf.Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,10 +306,13 @@ void Any::SerializeWithCachedSizes(
|
|||||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||||
(void)deterministic; // Unused
|
(void)deterministic; // Unused
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
|
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
|
||||||
// optional string type_url = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// string type_url = 1;
|
||||||
if (this->type_url().size() > 0) {
|
if (this->type_url().size() > 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->type_url().data(), this->type_url().length(),
|
this->type_url().data(), static_cast<int>(this->type_url().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.Any.type_url");
|
"google.protobuf.Any.type_url");
|
||||||
target =
|
target =
|
||||||
@@ -309,13 +320,17 @@ void Any::SerializeWithCachedSizes(
|
|||||||
1, this->type_url(), target);
|
1, this->type_url(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
if (this->value().size() > 0) {
|
if (this->value().size() > 0) {
|
||||||
target =
|
target =
|
||||||
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
|
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
|
||||||
2, this->value(), target);
|
2, this->value(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any)
|
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -324,14 +339,19 @@ size_t Any::ByteSizeLong() const {
|
|||||||
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)
|
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
// optional string type_url = 1;
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
total_size +=
|
||||||
|
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
|
||||||
|
}
|
||||||
|
// string type_url = 1;
|
||||||
if (this->type_url().size() > 0) {
|
if (this->type_url().size() > 0) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::google::protobuf::internal::WireFormatLite::StringSize(
|
::google::protobuf::internal::WireFormatLite::StringSize(
|
||||||
this->type_url());
|
this->type_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
if (this->value().size() > 0) {
|
if (this->value().size() > 0) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::google::protobuf::internal::WireFormatLite::BytesSize(
|
::google::protobuf::internal::WireFormatLite::BytesSize(
|
||||||
@@ -347,7 +367,7 @@ size_t Any::ByteSizeLong() const {
|
|||||||
|
|
||||||
void Any::MergeFrom(const ::google::protobuf::Message& from) {
|
void Any::MergeFrom(const ::google::protobuf::Message& from) {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any)
|
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any)
|
||||||
if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
const Any* source =
|
const Any* source =
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const Any>(
|
::google::protobuf::internal::DynamicCastToGenerated<const Any>(
|
||||||
&from);
|
&from);
|
||||||
@@ -356,21 +376,17 @@ void Any::MergeFrom(const ::google::protobuf::Message& from) {
|
|||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||||
} else {
|
} else {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any)
|
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any)
|
||||||
UnsafeMergeFrom(*source);
|
MergeFrom(*source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Any::MergeFrom(const Any& from) {
|
void Any::MergeFrom(const Any& from) {
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
|
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
|
||||||
if (GOOGLE_PREDICT_TRUE(&from != this)) {
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
} else {
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
MergeFromFail(__LINE__);
|
(void) cached_has_bits;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Any::UnsafeMergeFrom(const Any& from) {
|
|
||||||
GOOGLE_DCHECK(&from != this);
|
|
||||||
if (from.type_url().size() > 0) {
|
if (from.type_url().size() > 0) {
|
||||||
|
|
||||||
type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);
|
type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);
|
||||||
@@ -392,11 +408,10 @@ void Any::CopyFrom(const Any& from) {
|
|||||||
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any)
|
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
UnsafeMergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Any::IsInitialized() const {
|
bool Any::IsInitialized() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,118 +420,20 @@ void Any::Swap(Any* other) {
|
|||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
void Any::InternalSwap(Any* other) {
|
void Any::InternalSwap(Any* other) {
|
||||||
|
using std::swap;
|
||||||
type_url_.Swap(&other->type_url_);
|
type_url_.Swap(&other->type_url_);
|
||||||
value_.Swap(&other->value_);
|
value_.Swap(&other->value_);
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
swap(_cached_size_, other->_cached_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::Metadata Any::GetMetadata() const {
|
::google::protobuf::Metadata Any::GetMetadata() const {
|
||||||
protobuf_AssignDescriptorsOnce();
|
protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
::google::protobuf::Metadata metadata;
|
return ::protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[kIndexInFileMessages];
|
||||||
metadata.descriptor = Any_descriptor_;
|
|
||||||
metadata.reflection = Any_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// Any
|
|
||||||
|
|
||||||
// optional string type_url = 1;
|
|
||||||
void Any::clear_type_url() {
|
|
||||||
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
const ::std::string& Any::type_url() const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
|
|
||||||
return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void Any::set_type_url(const ::std::string& value) {
|
|
||||||
|
|
||||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
|
||||||
}
|
|
||||||
void Any::set_type_url(const char* value) {
|
|
||||||
|
|
||||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)
|
|
||||||
}
|
|
||||||
void Any::set_type_url(const char* value, size_t size) {
|
|
||||||
|
|
||||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char*>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url)
|
|
||||||
}
|
|
||||||
::std::string* Any::mutable_type_url() {
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url)
|
|
||||||
return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
::std::string* Any::release_type_url() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)
|
|
||||||
|
|
||||||
return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void Any::set_allocated_type_url(::std::string* type_url) {
|
|
||||||
if (type_url != NULL) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional bytes value = 2;
|
|
||||||
void Any::clear_value() {
|
|
||||||
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
const ::std::string& Any::value() const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
|
|
||||||
return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void Any::set_value(const ::std::string& value) {
|
|
||||||
|
|
||||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
|
||||||
}
|
|
||||||
void Any::set_value(const char* value) {
|
|
||||||
|
|
||||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)
|
|
||||||
}
|
|
||||||
void Any::set_value(const void* value, size_t size) {
|
|
||||||
|
|
||||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char*>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value)
|
|
||||||
}
|
|
||||||
::std::string* Any::mutable_value() {
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.Any.value)
|
|
||||||
return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
::std::string* Any::release_value() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.Any.value)
|
|
||||||
|
|
||||||
return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void Any::set_allocated_value(::std::string* value) {
|
|
||||||
if (value != NULL) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const Any* Any::internal_default_instance() {
|
|
||||||
return &Any_default_instance_.get();
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
|||||||
+107
-50
@@ -8,38 +8,56 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
#include <google/protobuf/any.h>
|
#include <google/protobuf/any.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fany_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[1];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsAnyImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsAny();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsAny();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fany_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
|
|
||||||
|
|
||||||
class Any;
|
class Any;
|
||||||
|
class AnyDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -54,11 +72,31 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Any(Any&& from) noexcept
|
||||||
|
: Any() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Any& operator=(Any&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Any& default_instance();
|
static const Any& default_instance();
|
||||||
|
|
||||||
static const Any* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Any* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Any*>(
|
||||||
|
&_Any_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
// implements Any -----------------------------------------------
|
// implements Any -----------------------------------------------
|
||||||
|
|
||||||
@@ -71,67 +109,72 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Swap(Any* other);
|
void Swap(Any* other);
|
||||||
|
friend void swap(Any& a, Any& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Any* New() const { return New(NULL); }
|
inline Any* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Any* New(::google::protobuf::Arena* arena) const;
|
Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Any& from);
|
void CopyFrom(const Any& from);
|
||||||
void MergeFrom(const Any& from);
|
void MergeFrom(const Any& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Any* other);
|
void InternalSwap(Any* other);
|
||||||
void UnsafeMergeFrom(const Any& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional string type_url = 1;
|
// string type_url = 1;
|
||||||
void clear_type_url();
|
void clear_type_url();
|
||||||
static const int kTypeUrlFieldNumber = 1;
|
static const int kTypeUrlFieldNumber = 1;
|
||||||
const ::std::string& type_url() const;
|
const ::std::string& type_url() const;
|
||||||
void set_type_url(const ::std::string& value);
|
void set_type_url(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_type_url(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_type_url(const char* value);
|
void set_type_url(const char* value);
|
||||||
void set_type_url(const char* value, size_t size);
|
void set_type_url(const char* value, size_t size);
|
||||||
::std::string* mutable_type_url();
|
::std::string* mutable_type_url();
|
||||||
::std::string* release_type_url();
|
::std::string* release_type_url();
|
||||||
void set_allocated_type_url(::std::string* type_url);
|
void set_allocated_type_url(::std::string* type_url);
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
void clear_value();
|
void clear_value();
|
||||||
static const int kValueFieldNumber = 2;
|
static const int kValueFieldNumber = 2;
|
||||||
const ::std::string& value() const;
|
const ::std::string& value() const;
|
||||||
void set_value(const ::std::string& value);
|
void set_value(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_value(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_value(const char* value);
|
void set_value(const char* value);
|
||||||
void set_value(const void* value, size_t size);
|
void set_value(const void* value, size_t size);
|
||||||
::std::string* mutable_value();
|
::std::string* mutable_value();
|
||||||
@@ -146,37 +189,43 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
::google::protobuf::internal::ArenaStringPtr value_;
|
::google::protobuf::internal::ArenaStringPtr value_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
::google::protobuf::internal::AnyMetadata _any_metadata_;
|
::google::protobuf::internal::AnyMetadata _any_metadata_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fany_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaultsAnyImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// Any
|
// Any
|
||||||
|
|
||||||
// optional string type_url = 1;
|
// string type_url = 1;
|
||||||
inline void Any::clear_type_url() {
|
inline void Any::clear_type_url() {
|
||||||
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Any::type_url() const {
|
inline const ::std::string& Any::type_url() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
|
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
|
||||||
return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return type_url_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Any::set_type_url(const ::std::string& value) {
|
inline void Any::set_type_url(const ::std::string& value) {
|
||||||
|
|
||||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Any::set_type_url(::std::string&& value) {
|
||||||
|
|
||||||
|
type_url_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Any::set_type_url(const char* value) {
|
inline void Any::set_type_url(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)
|
||||||
@@ -207,20 +256,29 @@ inline void Any::set_allocated_type_url(::std::string* type_url) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bytes value = 2;
|
// bytes value = 2;
|
||||||
inline void Any::clear_value() {
|
inline void Any::clear_value() {
|
||||||
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Any::value() const {
|
inline const ::std::string& Any::value() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
|
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
|
||||||
return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return value_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Any::set_value(const ::std::string& value) {
|
inline void Any::set_value(const ::std::string& value) {
|
||||||
|
|
||||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Any::set_value(::std::string&& value) {
|
||||||
|
|
||||||
|
value_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Any::set_value(const char* value) {
|
inline void Any::set_value(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)
|
||||||
@@ -251,10 +309,9 @@ inline void Any::set_allocated_value(::std::string* value) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Any* Any::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &Any_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
|
|||||||
+618
-1092
File diff suppressed because it is too large
Load Diff
+372
-226
@@ -8,41 +8,69 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
#include <google/protobuf/source_context.pb.h>
|
#include <google/protobuf/source_context.pb.h>
|
||||||
#include <google/protobuf/type.pb.h>
|
#include <google/protobuf/type.pb.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fapi_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[3];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsApiImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsApi();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsMethodImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsMethod();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsMixinImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsMixin();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsApi();
|
||||||
|
InitDefaultsMethod();
|
||||||
|
InitDefaultsMixin();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fapi_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
|
|
||||||
class Api;
|
class Api;
|
||||||
|
class ApiDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_;
|
||||||
class Method;
|
class Method;
|
||||||
|
class MethodDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_;
|
||||||
class Mixin;
|
class Mixin;
|
||||||
|
class MixinDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -57,69 +85,77 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Api(Api&& from) noexcept
|
||||||
|
: Api() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Api& operator=(Api&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Api& default_instance();
|
static const Api& default_instance();
|
||||||
|
|
||||||
static const Api* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Api* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Api*>(
|
||||||
|
&_Api_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
void Swap(Api* other);
|
void Swap(Api* other);
|
||||||
|
friend void swap(Api& a, Api& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Api* New() const { return New(NULL); }
|
inline Api* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Api* New(::google::protobuf::Arena* arena) const;
|
Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Api& from);
|
void CopyFrom(const Api& from);
|
||||||
void MergeFrom(const Api& from);
|
void MergeFrom(const Api& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Api* other);
|
void InternalSwap(Api* other);
|
||||||
void UnsafeMergeFrom(const Api& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional string name = 1;
|
|
||||||
void clear_name();
|
|
||||||
static const int kNameFieldNumber = 1;
|
|
||||||
const ::std::string& name() const;
|
|
||||||
void set_name(const ::std::string& value);
|
|
||||||
void set_name(const char* value);
|
|
||||||
void set_name(const char* value, size_t size);
|
|
||||||
::std::string* mutable_name();
|
|
||||||
::std::string* release_name();
|
|
||||||
void set_allocated_name(::std::string* name);
|
|
||||||
|
|
||||||
// repeated .google.protobuf.Method methods = 2;
|
// repeated .google.protobuf.Method methods = 2;
|
||||||
int methods_size() const;
|
int methods_size() const;
|
||||||
void clear_methods();
|
void clear_methods();
|
||||||
@@ -144,26 +180,6 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
||||||
options() const;
|
options() const;
|
||||||
|
|
||||||
// optional string version = 4;
|
|
||||||
void clear_version();
|
|
||||||
static const int kVersionFieldNumber = 4;
|
|
||||||
const ::std::string& version() const;
|
|
||||||
void set_version(const ::std::string& value);
|
|
||||||
void set_version(const char* value);
|
|
||||||
void set_version(const char* value, size_t size);
|
|
||||||
::std::string* mutable_version();
|
|
||||||
::std::string* release_version();
|
|
||||||
void set_allocated_version(::std::string* version);
|
|
||||||
|
|
||||||
// optional .google.protobuf.SourceContext source_context = 5;
|
|
||||||
bool has_source_context() const;
|
|
||||||
void clear_source_context();
|
|
||||||
static const int kSourceContextFieldNumber = 5;
|
|
||||||
const ::google::protobuf::SourceContext& source_context() const;
|
|
||||||
::google::protobuf::SourceContext* mutable_source_context();
|
|
||||||
::google::protobuf::SourceContext* release_source_context();
|
|
||||||
void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
|
|
||||||
|
|
||||||
// repeated .google.protobuf.Mixin mixins = 6;
|
// repeated .google.protobuf.Mixin mixins = 6;
|
||||||
int mixins_size() const;
|
int mixins_size() const;
|
||||||
void clear_mixins();
|
void clear_mixins();
|
||||||
@@ -176,7 +192,44 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
|
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
|
||||||
mixins() const;
|
mixins() const;
|
||||||
|
|
||||||
// optional .google.protobuf.Syntax syntax = 7;
|
// string name = 1;
|
||||||
|
void clear_name();
|
||||||
|
static const int kNameFieldNumber = 1;
|
||||||
|
const ::std::string& name() const;
|
||||||
|
void set_name(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_name(::std::string&& value);
|
||||||
|
#endif
|
||||||
|
void set_name(const char* value);
|
||||||
|
void set_name(const char* value, size_t size);
|
||||||
|
::std::string* mutable_name();
|
||||||
|
::std::string* release_name();
|
||||||
|
void set_allocated_name(::std::string* name);
|
||||||
|
|
||||||
|
// string version = 4;
|
||||||
|
void clear_version();
|
||||||
|
static const int kVersionFieldNumber = 4;
|
||||||
|
const ::std::string& version() const;
|
||||||
|
void set_version(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_version(::std::string&& value);
|
||||||
|
#endif
|
||||||
|
void set_version(const char* value);
|
||||||
|
void set_version(const char* value, size_t size);
|
||||||
|
::std::string* mutable_version();
|
||||||
|
::std::string* release_version();
|
||||||
|
void set_allocated_version(::std::string* version);
|
||||||
|
|
||||||
|
// .google.protobuf.SourceContext source_context = 5;
|
||||||
|
bool has_source_context() const;
|
||||||
|
void clear_source_context();
|
||||||
|
static const int kSourceContextFieldNumber = 5;
|
||||||
|
const ::google::protobuf::SourceContext& source_context() const;
|
||||||
|
::google::protobuf::SourceContext* release_source_context();
|
||||||
|
::google::protobuf::SourceContext* mutable_source_context();
|
||||||
|
void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
|
||||||
|
|
||||||
|
// .google.protobuf.Syntax syntax = 7;
|
||||||
void clear_syntax();
|
void clear_syntax();
|
||||||
static const int kSyntaxFieldNumber = 7;
|
static const int kSyntaxFieldNumber = 7;
|
||||||
::google::protobuf::Syntax syntax() const;
|
::google::protobuf::Syntax syntax() const;
|
||||||
@@ -194,15 +247,9 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||||||
::google::protobuf::SourceContext* source_context_;
|
::google::protobuf::SourceContext* source_context_;
|
||||||
int syntax_;
|
int syntax_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsApiImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
|
class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
|
||||||
@@ -216,103 +263,77 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Method(Method&& from) noexcept
|
||||||
|
: Method() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Method& operator=(Method&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Method& default_instance();
|
static const Method& default_instance();
|
||||||
|
|
||||||
static const Method* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Method* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Method*>(
|
||||||
|
&_Method_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
1;
|
||||||
|
|
||||||
void Swap(Method* other);
|
void Swap(Method* other);
|
||||||
|
friend void swap(Method& a, Method& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Method* New() const { return New(NULL); }
|
inline Method* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Method* New(::google::protobuf::Arena* arena) const;
|
Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Method& from);
|
void CopyFrom(const Method& from);
|
||||||
void MergeFrom(const Method& from);
|
void MergeFrom(const Method& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Method* other);
|
void InternalSwap(Method* other);
|
||||||
void UnsafeMergeFrom(const Method& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional string name = 1;
|
|
||||||
void clear_name();
|
|
||||||
static const int kNameFieldNumber = 1;
|
|
||||||
const ::std::string& name() const;
|
|
||||||
void set_name(const ::std::string& value);
|
|
||||||
void set_name(const char* value);
|
|
||||||
void set_name(const char* value, size_t size);
|
|
||||||
::std::string* mutable_name();
|
|
||||||
::std::string* release_name();
|
|
||||||
void set_allocated_name(::std::string* name);
|
|
||||||
|
|
||||||
// optional string request_type_url = 2;
|
|
||||||
void clear_request_type_url();
|
|
||||||
static const int kRequestTypeUrlFieldNumber = 2;
|
|
||||||
const ::std::string& request_type_url() const;
|
|
||||||
void set_request_type_url(const ::std::string& value);
|
|
||||||
void set_request_type_url(const char* value);
|
|
||||||
void set_request_type_url(const char* value, size_t size);
|
|
||||||
::std::string* mutable_request_type_url();
|
|
||||||
::std::string* release_request_type_url();
|
|
||||||
void set_allocated_request_type_url(::std::string* request_type_url);
|
|
||||||
|
|
||||||
// optional bool request_streaming = 3;
|
|
||||||
void clear_request_streaming();
|
|
||||||
static const int kRequestStreamingFieldNumber = 3;
|
|
||||||
bool request_streaming() const;
|
|
||||||
void set_request_streaming(bool value);
|
|
||||||
|
|
||||||
// optional string response_type_url = 4;
|
|
||||||
void clear_response_type_url();
|
|
||||||
static const int kResponseTypeUrlFieldNumber = 4;
|
|
||||||
const ::std::string& response_type_url() const;
|
|
||||||
void set_response_type_url(const ::std::string& value);
|
|
||||||
void set_response_type_url(const char* value);
|
|
||||||
void set_response_type_url(const char* value, size_t size);
|
|
||||||
::std::string* mutable_response_type_url();
|
|
||||||
::std::string* release_response_type_url();
|
|
||||||
void set_allocated_response_type_url(::std::string* response_type_url);
|
|
||||||
|
|
||||||
// optional bool response_streaming = 5;
|
|
||||||
void clear_response_streaming();
|
|
||||||
static const int kResponseStreamingFieldNumber = 5;
|
|
||||||
bool response_streaming() const;
|
|
||||||
void set_response_streaming(bool value);
|
|
||||||
|
|
||||||
// repeated .google.protobuf.Option options = 6;
|
// repeated .google.protobuf.Option options = 6;
|
||||||
int options_size() const;
|
int options_size() const;
|
||||||
void clear_options();
|
void clear_options();
|
||||||
@@ -325,7 +346,61 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||||||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
||||||
options() const;
|
options() const;
|
||||||
|
|
||||||
// optional .google.protobuf.Syntax syntax = 7;
|
// string name = 1;
|
||||||
|
void clear_name();
|
||||||
|
static const int kNameFieldNumber = 1;
|
||||||
|
const ::std::string& name() const;
|
||||||
|
void set_name(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_name(::std::string&& value);
|
||||||
|
#endif
|
||||||
|
void set_name(const char* value);
|
||||||
|
void set_name(const char* value, size_t size);
|
||||||
|
::std::string* mutable_name();
|
||||||
|
::std::string* release_name();
|
||||||
|
void set_allocated_name(::std::string* name);
|
||||||
|
|
||||||
|
// string request_type_url = 2;
|
||||||
|
void clear_request_type_url();
|
||||||
|
static const int kRequestTypeUrlFieldNumber = 2;
|
||||||
|
const ::std::string& request_type_url() const;
|
||||||
|
void set_request_type_url(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_request_type_url(::std::string&& value);
|
||||||
|
#endif
|
||||||
|
void set_request_type_url(const char* value);
|
||||||
|
void set_request_type_url(const char* value, size_t size);
|
||||||
|
::std::string* mutable_request_type_url();
|
||||||
|
::std::string* release_request_type_url();
|
||||||
|
void set_allocated_request_type_url(::std::string* request_type_url);
|
||||||
|
|
||||||
|
// string response_type_url = 4;
|
||||||
|
void clear_response_type_url();
|
||||||
|
static const int kResponseTypeUrlFieldNumber = 4;
|
||||||
|
const ::std::string& response_type_url() const;
|
||||||
|
void set_response_type_url(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_response_type_url(::std::string&& value);
|
||||||
|
#endif
|
||||||
|
void set_response_type_url(const char* value);
|
||||||
|
void set_response_type_url(const char* value, size_t size);
|
||||||
|
::std::string* mutable_response_type_url();
|
||||||
|
::std::string* release_response_type_url();
|
||||||
|
void set_allocated_response_type_url(::std::string* response_type_url);
|
||||||
|
|
||||||
|
// bool request_streaming = 3;
|
||||||
|
void clear_request_streaming();
|
||||||
|
static const int kRequestStreamingFieldNumber = 3;
|
||||||
|
bool request_streaming() const;
|
||||||
|
void set_request_streaming(bool value);
|
||||||
|
|
||||||
|
// bool response_streaming = 5;
|
||||||
|
void clear_response_streaming();
|
||||||
|
static const int kResponseStreamingFieldNumber = 5;
|
||||||
|
bool response_streaming() const;
|
||||||
|
void set_response_streaming(bool value);
|
||||||
|
|
||||||
|
// .google.protobuf.Syntax syntax = 7;
|
||||||
void clear_syntax();
|
void clear_syntax();
|
||||||
static const int kSyntaxFieldNumber = 7;
|
static const int kSyntaxFieldNumber = 7;
|
||||||
::google::protobuf::Syntax syntax() const;
|
::google::protobuf::Syntax syntax() const;
|
||||||
@@ -343,15 +418,9 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||||||
bool response_streaming_;
|
bool response_streaming_;
|
||||||
int syntax_;
|
int syntax_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMethodImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
|
class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
|
||||||
@@ -365,74 +434,99 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Mixin(Mixin&& from) noexcept
|
||||||
|
: Mixin() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Mixin& operator=(Mixin&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Mixin& default_instance();
|
static const Mixin& default_instance();
|
||||||
|
|
||||||
static const Mixin* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Mixin* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Mixin*>(
|
||||||
|
&_Mixin_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
2;
|
||||||
|
|
||||||
void Swap(Mixin* other);
|
void Swap(Mixin* other);
|
||||||
|
friend void swap(Mixin& a, Mixin& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Mixin* New() const { return New(NULL); }
|
inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Mixin* New(::google::protobuf::Arena* arena) const;
|
Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Mixin& from);
|
void CopyFrom(const Mixin& from);
|
||||||
void MergeFrom(const Mixin& from);
|
void MergeFrom(const Mixin& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Mixin* other);
|
void InternalSwap(Mixin* other);
|
||||||
void UnsafeMergeFrom(const Mixin& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional string name = 1;
|
// string name = 1;
|
||||||
void clear_name();
|
void clear_name();
|
||||||
static const int kNameFieldNumber = 1;
|
static const int kNameFieldNumber = 1;
|
||||||
const ::std::string& name() const;
|
const ::std::string& name() const;
|
||||||
void set_name(const ::std::string& value);
|
void set_name(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_name(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_name(const char* value);
|
void set_name(const char* value);
|
||||||
void set_name(const char* value, size_t size);
|
void set_name(const char* value, size_t size);
|
||||||
::std::string* mutable_name();
|
::std::string* mutable_name();
|
||||||
::std::string* release_name();
|
::std::string* release_name();
|
||||||
void set_allocated_name(::std::string* name);
|
void set_allocated_name(::std::string* name);
|
||||||
|
|
||||||
// optional string root = 2;
|
// string root = 2;
|
||||||
void clear_root();
|
void clear_root();
|
||||||
static const int kRootFieldNumber = 2;
|
static const int kRootFieldNumber = 2;
|
||||||
const ::std::string& root() const;
|
const ::std::string& root() const;
|
||||||
void set_root(const ::std::string& value);
|
void set_root(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_root(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_root(const char* value);
|
void set_root(const char* value);
|
||||||
void set_root(const char* value, size_t size);
|
void set_root(const char* value, size_t size);
|
||||||
::std::string* mutable_root();
|
::std::string* mutable_root();
|
||||||
@@ -446,37 +540,43 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||||||
::google::protobuf::internal::ArenaStringPtr name_;
|
::google::protobuf::internal::ArenaStringPtr name_;
|
||||||
::google::protobuf::internal::ArenaStringPtr root_;
|
::google::protobuf::internal::ArenaStringPtr root_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaultsMixinImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// Api
|
// Api
|
||||||
|
|
||||||
// optional string name = 1;
|
// string name = 1;
|
||||||
inline void Api::clear_name() {
|
inline void Api::clear_name() {
|
||||||
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Api::name() const {
|
inline const ::std::string& Api::name() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Api.name)
|
// @@protoc_insertion_point(field_get:google.protobuf.Api.name)
|
||||||
return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return name_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Api::set_name(const ::std::string& value) {
|
inline void Api::set_name(const ::std::string& value) {
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
|
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Api::set_name(::std::string&& value) {
|
||||||
|
|
||||||
|
name_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Api::set_name(const char* value) {
|
inline void Api::set_name(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Api.name)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Api.name)
|
||||||
@@ -541,9 +641,6 @@ Api::methods() const {
|
|||||||
inline int Api::options_size() const {
|
inline int Api::options_size() const {
|
||||||
return options_.size();
|
return options_.size();
|
||||||
}
|
}
|
||||||
inline void Api::clear_options() {
|
|
||||||
options_.Clear();
|
|
||||||
}
|
|
||||||
inline const ::google::protobuf::Option& Api::options(int index) const {
|
inline const ::google::protobuf::Option& Api::options(int index) const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Api.options)
|
// @@protoc_insertion_point(field_get:google.protobuf.Api.options)
|
||||||
return options_.Get(index);
|
return options_.Get(index);
|
||||||
@@ -567,20 +664,29 @@ Api::options() const {
|
|||||||
return options_;
|
return options_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional string version = 4;
|
// string version = 4;
|
||||||
inline void Api::clear_version() {
|
inline void Api::clear_version() {
|
||||||
version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Api::version() const {
|
inline const ::std::string& Api::version() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Api.version)
|
// @@protoc_insertion_point(field_get:google.protobuf.Api.version)
|
||||||
return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return version_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Api::set_version(const ::std::string& value) {
|
inline void Api::set_version(const ::std::string& value) {
|
||||||
|
|
||||||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
|
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Api::set_version(::std::string&& value) {
|
||||||
|
|
||||||
|
version_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Api::set_version(const char* value) {
|
inline void Api::set_version(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Api.version)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Api.version)
|
||||||
@@ -611,18 +717,22 @@ inline void Api::set_allocated_version(::std::string* version) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional .google.protobuf.SourceContext source_context = 5;
|
// .google.protobuf.SourceContext source_context = 5;
|
||||||
inline bool Api::has_source_context() const {
|
inline bool Api::has_source_context() const {
|
||||||
return this != internal_default_instance() && source_context_ != NULL;
|
return this != internal_default_instance() && source_context_ != NULL;
|
||||||
}
|
}
|
||||||
inline void Api::clear_source_context() {
|
|
||||||
if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;
|
|
||||||
source_context_ = NULL;
|
|
||||||
}
|
|
||||||
inline const ::google::protobuf::SourceContext& Api::source_context() const {
|
inline const ::google::protobuf::SourceContext& Api::source_context() const {
|
||||||
|
const ::google::protobuf::SourceContext* p = source_context_;
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Api.source_context)
|
// @@protoc_insertion_point(field_get:google.protobuf.Api.source_context)
|
||||||
return source_context_ != NULL ? *source_context_
|
return p != NULL ? *p : *reinterpret_cast<const ::google::protobuf::SourceContext*>(
|
||||||
: *::google::protobuf::SourceContext::internal_default_instance();
|
&::google::protobuf::_SourceContext_default_instance_);
|
||||||
|
}
|
||||||
|
inline ::google::protobuf::SourceContext* Api::release_source_context() {
|
||||||
|
// @@protoc_insertion_point(field_release:google.protobuf.Api.source_context)
|
||||||
|
|
||||||
|
::google::protobuf::SourceContext* temp = source_context_;
|
||||||
|
source_context_ = NULL;
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::SourceContext* Api::mutable_source_context() {
|
inline ::google::protobuf::SourceContext* Api::mutable_source_context() {
|
||||||
|
|
||||||
@@ -632,21 +742,22 @@ inline ::google::protobuf::SourceContext* Api::mutable_source_context() {
|
|||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context)
|
// @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context)
|
||||||
return source_context_;
|
return source_context_;
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::SourceContext* Api::release_source_context() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.Api.source_context)
|
|
||||||
|
|
||||||
::google::protobuf::SourceContext* temp = source_context_;
|
|
||||||
source_context_ = NULL;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
inline void Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {
|
inline void Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {
|
||||||
delete source_context_;
|
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
|
||||||
source_context_ = source_context;
|
if (message_arena == NULL) {
|
||||||
|
delete reinterpret_cast< ::google::protobuf::MessageLite*>(source_context_);
|
||||||
|
}
|
||||||
if (source_context) {
|
if (source_context) {
|
||||||
|
::google::protobuf::Arena* submessage_arena = NULL;
|
||||||
|
if (message_arena != submessage_arena) {
|
||||||
|
source_context = ::google::protobuf::internal::GetOwnedMessage(
|
||||||
|
message_arena, source_context, submessage_arena);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
source_context_ = source_context;
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,7 +791,7 @@ Api::mixins() const {
|
|||||||
return mixins_;
|
return mixins_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional .google.protobuf.Syntax syntax = 7;
|
// .google.protobuf.Syntax syntax = 7;
|
||||||
inline void Api::clear_syntax() {
|
inline void Api::clear_syntax() {
|
||||||
syntax_ = 0;
|
syntax_ = 0;
|
||||||
}
|
}
|
||||||
@@ -694,27 +805,33 @@ inline void Api::set_syntax(::google::protobuf::Syntax value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)
|
// @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Api* Api::internal_default_instance() {
|
|
||||||
return &Api_default_instance_.get();
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// Method
|
// Method
|
||||||
|
|
||||||
// optional string name = 1;
|
// string name = 1;
|
||||||
inline void Method::clear_name() {
|
inline void Method::clear_name() {
|
||||||
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Method::name() const {
|
inline const ::std::string& Method::name() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Method.name)
|
// @@protoc_insertion_point(field_get:google.protobuf.Method.name)
|
||||||
return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return name_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Method::set_name(const ::std::string& value) {
|
inline void Method::set_name(const ::std::string& value) {
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
|
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Method::set_name(::std::string&& value) {
|
||||||
|
|
||||||
|
name_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Method::set_name(const char* value) {
|
inline void Method::set_name(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.name)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.name)
|
||||||
@@ -745,20 +862,29 @@ inline void Method::set_allocated_name(::std::string* name) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional string request_type_url = 2;
|
// string request_type_url = 2;
|
||||||
inline void Method::clear_request_type_url() {
|
inline void Method::clear_request_type_url() {
|
||||||
request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Method::request_type_url() const {
|
inline const ::std::string& Method::request_type_url() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
|
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
|
||||||
return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return request_type_url_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Method::set_request_type_url(const ::std::string& value) {
|
inline void Method::set_request_type_url(const ::std::string& value) {
|
||||||
|
|
||||||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
|
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Method::set_request_type_url(::std::string&& value) {
|
||||||
|
|
||||||
|
request_type_url_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Method::set_request_type_url(const char* value) {
|
inline void Method::set_request_type_url(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url)
|
||||||
@@ -789,7 +915,7 @@ inline void Method::set_allocated_request_type_url(::std::string* request_type_u
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bool request_streaming = 3;
|
// bool request_streaming = 3;
|
||||||
inline void Method::clear_request_streaming() {
|
inline void Method::clear_request_streaming() {
|
||||||
request_streaming_ = false;
|
request_streaming_ = false;
|
||||||
}
|
}
|
||||||
@@ -803,20 +929,29 @@ inline void Method::set_request_streaming(bool value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)
|
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional string response_type_url = 4;
|
// string response_type_url = 4;
|
||||||
inline void Method::clear_response_type_url() {
|
inline void Method::clear_response_type_url() {
|
||||||
response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Method::response_type_url() const {
|
inline const ::std::string& Method::response_type_url() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
|
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
|
||||||
return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return response_type_url_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Method::set_response_type_url(const ::std::string& value) {
|
inline void Method::set_response_type_url(const ::std::string& value) {
|
||||||
|
|
||||||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
|
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Method::set_response_type_url(::std::string&& value) {
|
||||||
|
|
||||||
|
response_type_url_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Method::set_response_type_url(const char* value) {
|
inline void Method::set_response_type_url(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url)
|
||||||
@@ -847,7 +982,7 @@ inline void Method::set_allocated_response_type_url(::std::string* response_type
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bool response_streaming = 5;
|
// bool response_streaming = 5;
|
||||||
inline void Method::clear_response_streaming() {
|
inline void Method::clear_response_streaming() {
|
||||||
response_streaming_ = false;
|
response_streaming_ = false;
|
||||||
}
|
}
|
||||||
@@ -865,9 +1000,6 @@ inline void Method::set_response_streaming(bool value) {
|
|||||||
inline int Method::options_size() const {
|
inline int Method::options_size() const {
|
||||||
return options_.size();
|
return options_.size();
|
||||||
}
|
}
|
||||||
inline void Method::clear_options() {
|
|
||||||
options_.Clear();
|
|
||||||
}
|
|
||||||
inline const ::google::protobuf::Option& Method::options(int index) const {
|
inline const ::google::protobuf::Option& Method::options(int index) const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Method.options)
|
// @@protoc_insertion_point(field_get:google.protobuf.Method.options)
|
||||||
return options_.Get(index);
|
return options_.Get(index);
|
||||||
@@ -891,7 +1023,7 @@ Method::options() const {
|
|||||||
return options_;
|
return options_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional .google.protobuf.Syntax syntax = 7;
|
// .google.protobuf.Syntax syntax = 7;
|
||||||
inline void Method::clear_syntax() {
|
inline void Method::clear_syntax() {
|
||||||
syntax_ = 0;
|
syntax_ = 0;
|
||||||
}
|
}
|
||||||
@@ -905,27 +1037,33 @@ inline void Method::set_syntax(::google::protobuf::Syntax value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)
|
// @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Method* Method::internal_default_instance() {
|
|
||||||
return &Method_default_instance_.get();
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// Mixin
|
// Mixin
|
||||||
|
|
||||||
// optional string name = 1;
|
// string name = 1;
|
||||||
inline void Mixin::clear_name() {
|
inline void Mixin::clear_name() {
|
||||||
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Mixin::name() const {
|
inline const ::std::string& Mixin::name() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
|
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
|
||||||
return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return name_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Mixin::set_name(const ::std::string& value) {
|
inline void Mixin::set_name(const ::std::string& value) {
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
|
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Mixin::set_name(::std::string&& value) {
|
||||||
|
|
||||||
|
name_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Mixin::set_name(const char* value) {
|
inline void Mixin::set_name(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name)
|
||||||
@@ -956,20 +1094,29 @@ inline void Mixin::set_allocated_name(::std::string* name) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional string root = 2;
|
// string root = 2;
|
||||||
inline void Mixin::clear_root() {
|
inline void Mixin::clear_root() {
|
||||||
root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& Mixin::root() const {
|
inline const ::std::string& Mixin::root() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
|
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
|
||||||
return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return root_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void Mixin::set_root(const ::std::string& value) {
|
inline void Mixin::set_root(const ::std::string& value) {
|
||||||
|
|
||||||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
|
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Mixin::set_root(::std::string&& value) {
|
||||||
|
|
||||||
|
root_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Mixin::set_root(const char* value) {
|
inline void Mixin::set_root(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root)
|
||||||
@@ -1000,10 +1147,9 @@ inline void Mixin::set_allocated_root(::std::string* root) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Mixin* Mixin::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &Mixin_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|||||||
+245
-176
@@ -36,280 +36,349 @@
|
|||||||
|
|
||||||
#ifdef ADDRESS_SANITIZER
|
#ifdef ADDRESS_SANITIZER
|
||||||
#include <sanitizer/asan_interface.h>
|
#include <sanitizer/asan_interface.h>
|
||||||
#endif
|
#endif // ADDRESS_SANITIZER
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
static const size_t kMinCleanupListElements = 8;
|
||||||
|
static const size_t kMaxCleanupListElements = 64; // 1kB on 64-bit.
|
||||||
|
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_;
|
google::protobuf::internal::SequenceNumber ArenaImpl::lifecycle_id_generator_;
|
||||||
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
||||||
Arena::ThreadCache& Arena::thread_cache() {
|
ArenaImpl::ThreadCache& ArenaImpl::thread_cache() {
|
||||||
static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =
|
static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =
|
||||||
new internal::ThreadLocalStorage<ThreadCache>();
|
new internal::ThreadLocalStorage<ThreadCache>();
|
||||||
return *thread_cache_->Get();
|
return *thread_cache_->Get();
|
||||||
}
|
}
|
||||||
#elif defined(PROTOBUF_USE_DLLS)
|
#elif defined(PROTOBUF_USE_DLLS)
|
||||||
Arena::ThreadCache& Arena::thread_cache() {
|
ArenaImpl::ThreadCache& ArenaImpl::thread_cache() {
|
||||||
static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL };
|
static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL };
|
||||||
return thread_cache_;
|
return thread_cache_;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL };
|
GOOGLE_THREAD_LOCAL ArenaImpl::ThreadCache ArenaImpl::thread_cache_ = {-1, NULL};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Arena::Init() {
|
void ArenaImpl::Init() {
|
||||||
lifecycle_id_ = lifecycle_id_generator_.GetNext();
|
lifecycle_id_ = lifecycle_id_generator_.GetNext();
|
||||||
blocks_ = 0;
|
google::protobuf::internal::NoBarrier_Store(&hint_, 0);
|
||||||
hint_ = 0;
|
google::protobuf::internal::NoBarrier_Store(&threads_, 0);
|
||||||
owns_first_block_ = true;
|
|
||||||
cleanup_list_ = 0;
|
|
||||||
|
|
||||||
if (options_.initial_block != NULL && options_.initial_block_size > 0) {
|
if (initial_block_) {
|
||||||
GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block))
|
|
||||||
<< ": Initial block size too small for header.";
|
|
||||||
|
|
||||||
// Add first unowned block to list.
|
|
||||||
Block* first_block = reinterpret_cast<Block*>(options_.initial_block);
|
|
||||||
first_block->size = options_.initial_block_size;
|
|
||||||
first_block->pos = kHeaderSize;
|
|
||||||
first_block->next = NULL;
|
|
||||||
// Thread which calls Init() owns the first block. This allows the
|
// Thread which calls Init() owns the first block. This allows the
|
||||||
// single-threaded case to allocate on the first block without taking any
|
// single-threaded case to allocate on the first block without having to
|
||||||
// locks.
|
// perform atomic operations.
|
||||||
first_block->owner = &thread_cache();
|
InitBlock(initial_block_, &thread_cache(), options_.initial_block_size);
|
||||||
SetThreadCacheBlock(first_block);
|
ThreadInfo* info = NewThreadInfo(initial_block_);
|
||||||
AddBlockInternal(first_block);
|
info->next = NULL;
|
||||||
owns_first_block_ = false;
|
google::protobuf::internal::NoBarrier_Store(&threads_,
|
||||||
}
|
reinterpret_cast<google::protobuf::internal::AtomicWord>(info));
|
||||||
|
google::protobuf::internal::NoBarrier_Store(&space_allocated_,
|
||||||
// Call the initialization hook
|
options_.initial_block_size);
|
||||||
if (options_.on_arena_init != NULL) {
|
CacheBlock(initial_block_);
|
||||||
hooks_cookie_ = options_.on_arena_init(this);
|
|
||||||
} else {
|
} else {
|
||||||
hooks_cookie_ = NULL;
|
google::protobuf::internal::NoBarrier_Store(&space_allocated_, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena::~Arena() {
|
ArenaImpl::~ArenaImpl() {
|
||||||
uint64 space_allocated = ResetInternal();
|
// Have to do this in a first pass, because some of the destructors might
|
||||||
|
// refer to memory in other blocks.
|
||||||
// Call the destruction hook
|
CleanupList();
|
||||||
if (options_.on_arena_destruction != NULL) {
|
FreeBlocks();
|
||||||
options_.on_arena_destruction(this, hooks_cookie_, space_allocated);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 Arena::Reset() {
|
uint64 ArenaImpl::Reset() {
|
||||||
// Invalidate any ThreadCaches pointing to any blocks we just destroyed.
|
// Have to do this in a first pass, because some of the destructors might
|
||||||
lifecycle_id_ = lifecycle_id_generator_.GetNext();
|
// refer to memory in other blocks.
|
||||||
return ResetInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64 Arena::ResetInternal() {
|
|
||||||
CleanupList();
|
CleanupList();
|
||||||
uint64 space_allocated = FreeBlocks();
|
uint64 space_allocated = FreeBlocks();
|
||||||
|
Init();
|
||||||
// Call the reset hook
|
|
||||||
if (options_.on_arena_reset != NULL) {
|
|
||||||
options_.on_arena_reset(this, hooks_cookie_, space_allocated);
|
|
||||||
}
|
|
||||||
|
|
||||||
return space_allocated;
|
return space_allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n,
|
ArenaImpl::Block* ArenaImpl::NewBlock(void* me, Block* my_last_block,
|
||||||
size_t start_block_size, size_t max_block_size) {
|
size_t min_bytes) {
|
||||||
size_t size;
|
size_t size;
|
||||||
if (my_last_block != NULL) {
|
if (my_last_block != NULL) {
|
||||||
// Double the current block size, up to a limit.
|
// Double the current block size, up to a limit.
|
||||||
size = 2 * (my_last_block->size);
|
size = std::min(2 * my_last_block->size, options_.max_block_size);
|
||||||
if (size > max_block_size) size = max_block_size;
|
|
||||||
} else {
|
} else {
|
||||||
size = start_block_size;
|
size = options_.start_block_size;
|
||||||
}
|
}
|
||||||
// Verify that n + kHeaderSize won't overflow.
|
// Verify that min_bytes + kHeaderSize won't overflow.
|
||||||
GOOGLE_CHECK_LE(n, std::numeric_limits<size_t>::max() - kHeaderSize);
|
GOOGLE_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() - kHeaderSize);
|
||||||
size = std::max(size, kHeaderSize + n);
|
size = std::max(size, kHeaderSize + min_bytes);
|
||||||
|
|
||||||
Block* b = reinterpret_cast<Block*>(options_.block_alloc(size));
|
Block* b = reinterpret_cast<Block*>(options_.block_alloc(size));
|
||||||
b->pos = kHeaderSize + n;
|
InitBlock(b, me, size);
|
||||||
|
google::protobuf::internal::NoBarrier_AtomicIncrement(&space_allocated_, size);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaImpl::InitBlock(Block* b, void *me, size_t size) {
|
||||||
|
b->pos = kHeaderSize;
|
||||||
b->size = size;
|
b->size = size;
|
||||||
b->owner = me;
|
b->owner = me;
|
||||||
|
b->next = NULL;
|
||||||
#ifdef ADDRESS_SANITIZER
|
#ifdef ADDRESS_SANITIZER
|
||||||
// Poison the rest of the block for ASAN. It was unpoisoned by the underlying
|
// Poison the rest of the block for ASAN. It was unpoisoned by the underlying
|
||||||
// malloc but it's not yet usable until we return it as part of an allocation.
|
// malloc but it's not yet usable until we return it as part of an allocation.
|
||||||
ASAN_POISON_MEMORY_REGION(
|
ASAN_POISON_MEMORY_REGION(
|
||||||
reinterpret_cast<char*>(b) + b->pos, b->size - b->pos);
|
reinterpret_cast<char*>(b) + b->pos, b->size - b->pos);
|
||||||
#endif
|
#endif // ADDRESS_SANITIZER
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arena::AddBlock(Block* b) {
|
ArenaImpl::CleanupChunk* ArenaImpl::ExpandCleanupList(CleanupChunk* cleanup,
|
||||||
MutexLock l(&blocks_lock_);
|
Block* b) {
|
||||||
AddBlockInternal(b);
|
size_t size = cleanup ? cleanup->size * 2 : kMinCleanupListElements;
|
||||||
}
|
size = std::min(size, kMaxCleanupListElements);
|
||||||
|
size_t bytes = internal::AlignUpTo8(CleanupChunk::SizeOf(size));
|
||||||
void Arena::AddBlockInternal(Block* b) {
|
if (b->avail() < bytes) {
|
||||||
b->next = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
b = GetBlock(bytes);
|
||||||
google::protobuf::internal::Release_Store(&blocks_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
|
|
||||||
if (b->avail() != 0) {
|
|
||||||
// Direct future allocations to this block.
|
|
||||||
google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
|
|
||||||
}
|
}
|
||||||
|
CleanupChunk* list =
|
||||||
|
reinterpret_cast<CleanupChunk*>(AllocFromBlock(b, bytes));
|
||||||
|
list->next = b->thread_info->cleanup;
|
||||||
|
list->size = size;
|
||||||
|
list->len = 0;
|
||||||
|
b->thread_info->cleanup = list;
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arena::AddListNode(void* elem, void (*cleanup)(void*)) {
|
inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
Node* node = reinterpret_cast<Node*>(AllocateAligned(sizeof(Node)));
|
void ArenaImpl::AddCleanupInBlock(
|
||||||
|
Block* b, void* elem, void (*func)(void*)) {
|
||||||
|
CleanupChunk* cleanup = b->thread_info->cleanup;
|
||||||
|
if (cleanup == NULL || cleanup->len == cleanup->size) {
|
||||||
|
cleanup = ExpandCleanupList(cleanup, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
CleanupNode* node = &cleanup->nodes[cleanup->len++];
|
||||||
|
|
||||||
node->elem = elem;
|
node->elem = elem;
|
||||||
node->cleanup = cleanup;
|
node->cleanup = func;
|
||||||
node->next = reinterpret_cast<Node*>(
|
|
||||||
google::protobuf::internal::NoBarrier_AtomicExchange(&cleanup_list_,
|
|
||||||
reinterpret_cast<google::protobuf::internal::AtomicWord>(node)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Arena::AllocateAligned(const std::type_info* allocated, size_t n) {
|
void ArenaImpl::AddCleanup(void* elem, void (*cleanup)(void*)) {
|
||||||
// Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)
|
return AddCleanupInBlock(GetBlock(0), elem, cleanup);
|
||||||
n = (n + 7) & -8;
|
}
|
||||||
|
|
||||||
// Monitor allocation if needed.
|
void* ArenaImpl::AllocateAligned(size_t n) {
|
||||||
if (GOOGLE_PREDICT_FALSE(hooks_cookie_ != NULL) &&
|
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
||||||
options_.on_arena_allocation != NULL) {
|
|
||||||
options_.on_arena_allocation(allocated, n, hooks_cookie_);
|
return AllocFromBlock(GetBlock(n), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* ArenaImpl::AllocateAlignedAndAddCleanup(size_t n,
|
||||||
|
void (*cleanup)(void*)) {
|
||||||
|
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
||||||
|
|
||||||
|
Block* b = GetBlock(n);
|
||||||
|
void* mem = AllocFromBlock(b, n);
|
||||||
|
AddCleanupInBlock(b, mem, cleanup);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
ArenaImpl::Block* ArenaImpl::GetBlock(size_t n) {
|
||||||
|
Block* my_block = NULL;
|
||||||
|
|
||||||
// If this thread already owns a block in this arena then try to use that.
|
// If this thread already owns a block in this arena then try to use that.
|
||||||
// This fast path optimizes the case where multiple threads allocate from the
|
// This fast path optimizes the case where multiple threads allocate from the
|
||||||
// same arena.
|
// same arena.
|
||||||
if (thread_cache().last_lifecycle_id_seen == lifecycle_id_ &&
|
ThreadCache* tc = &thread_cache();
|
||||||
thread_cache().last_block_used_ != NULL) {
|
if (tc->last_lifecycle_id_seen == lifecycle_id_) {
|
||||||
if (thread_cache().last_block_used_->avail() < n) {
|
my_block = tc->last_block_used_;
|
||||||
return SlowAlloc(n);
|
if (my_block->avail() >= n) {
|
||||||
|
return my_block;
|
||||||
}
|
}
|
||||||
return AllocFromBlock(thread_cache().last_block_used_, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we own the last accessed block on this arena.
|
// Check whether we own the last accessed block on this arena.
|
||||||
// This fast path optimizes the case where a single thread uses multiple
|
// This fast path optimizes the case where a single thread uses multiple
|
||||||
// arenas.
|
// arenas.
|
||||||
void* me = &thread_cache();
|
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&hint_));
|
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&hint_));
|
||||||
if (!b || b->owner != me || b->avail() < n) {
|
if (b != NULL && b->owner == tc) {
|
||||||
return SlowAlloc(n);
|
my_block = b;
|
||||||
|
if (my_block->avail() >= n) {
|
||||||
|
return my_block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AllocFromBlock(b, n);
|
return GetBlockSlow(tc, my_block, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Arena::AllocFromBlock(Block* b, size_t n) {
|
inline GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
void* ArenaImpl::AllocFromBlock(Block* b, size_t n) {
|
||||||
|
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(b->pos), b->pos); // Must be already aligned.
|
||||||
|
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
||||||
|
GOOGLE_DCHECK_GE(b->avail(), n);
|
||||||
size_t p = b->pos;
|
size_t p = b->pos;
|
||||||
b->pos = p + n;
|
b->pos = p + n;
|
||||||
#ifdef ADDRESS_SANITIZER
|
#ifdef ADDRESS_SANITIZER
|
||||||
ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n);
|
ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n);
|
||||||
#endif
|
#endif // ADDRESS_SANITIZER
|
||||||
return reinterpret_cast<char*>(b) + p;
|
return reinterpret_cast<char*>(b) + p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Arena::SlowAlloc(size_t n) {
|
ArenaImpl::Block* ArenaImpl::GetBlockSlow(void* me, Block* my_full_block,
|
||||||
void* me = &thread_cache();
|
size_t n) {
|
||||||
Block* b = FindBlock(me); // Find block owned by me.
|
ThreadInfo* info =
|
||||||
// See if allocation fits in my latest block.
|
my_full_block ? my_full_block->thread_info : GetThreadInfo(me, n);
|
||||||
if (b != NULL && b->avail() >= n) {
|
GOOGLE_DCHECK(info != NULL);
|
||||||
SetThreadCacheBlock(b);
|
Block* b = info->head;
|
||||||
google::protobuf::internal::NoBarrier_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
|
if (b->avail() < n) {
|
||||||
return AllocFromBlock(b, n);
|
Block* new_b = NewBlock(me, b, n);
|
||||||
|
new_b->thread_info = info;
|
||||||
|
new_b->next = b;
|
||||||
|
info->head = new_b;
|
||||||
|
b = new_b;
|
||||||
}
|
}
|
||||||
b = NewBlock(me, b, n, options_.start_block_size, options_.max_block_size);
|
CacheBlock(b);
|
||||||
AddBlock(b);
|
return b;
|
||||||
SetThreadCacheBlock(b);
|
|
||||||
return reinterpret_cast<char*>(b) + kHeaderSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 Arena::SpaceAllocated() const {
|
uint64 ArenaImpl::SpaceAllocated() const {
|
||||||
uint64 space_allocated = 0;
|
return google::protobuf::internal::NoBarrier_Load(&space_allocated_);
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
|
||||||
while (b != NULL) {
|
|
||||||
space_allocated += (b->size);
|
|
||||||
b = b->next;
|
|
||||||
}
|
|
||||||
return space_allocated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 Arena::SpaceUsed() const {
|
uint64 ArenaImpl::SpaceUsed() const {
|
||||||
|
ThreadInfo* info =
|
||||||
|
reinterpret_cast<ThreadInfo*>(google::protobuf::internal::Acquire_Load(&threads_));
|
||||||
uint64 space_used = 0;
|
uint64 space_used = 0;
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
|
||||||
while (b != NULL) {
|
for ( ; info; info = info->next) {
|
||||||
space_used += (b->pos - kHeaderSize);
|
// Remove the overhead of the ThreadInfo itself.
|
||||||
b = b->next;
|
space_used -= sizeof(ThreadInfo);
|
||||||
|
for (Block* b = info->head; b; b = b->next) {
|
||||||
|
space_used += (b->pos - kHeaderSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return space_used;
|
return space_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
|
uint64 ArenaImpl::FreeBlocks() {
|
||||||
uint64 allocated = 0;
|
|
||||||
uint64 used = 0;
|
|
||||||
|
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
|
||||||
while (b != NULL) {
|
|
||||||
allocated += b->size;
|
|
||||||
used += (b->pos - kHeaderSize);
|
|
||||||
b = b->next;
|
|
||||||
}
|
|
||||||
return std::make_pair(allocated, used);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64 Arena::FreeBlocks() {
|
|
||||||
uint64 space_allocated = 0;
|
uint64 space_allocated = 0;
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
// By omitting an Acquire barrier we ensure that any user code that doesn't
|
||||||
Block* first_block = NULL;
|
// properly synchronize Reset() or the destructor will throw a TSAN warning.
|
||||||
while (b != NULL) {
|
ThreadInfo* info =
|
||||||
space_allocated += (b->size);
|
reinterpret_cast<ThreadInfo*>(google::protobuf::internal::NoBarrier_Load(&threads_));
|
||||||
Block* next = b->next;
|
|
||||||
if (next != NULL) {
|
while (info) {
|
||||||
options_.block_dealloc(b, b->size);
|
// This is inside the block we are freeing, so we need to read it now.
|
||||||
} else {
|
ThreadInfo* next_info = info->next;
|
||||||
if (owns_first_block_) {
|
for (Block* b = info->head; b; ) {
|
||||||
|
// This is inside the block we are freeing, so we need to read it now.
|
||||||
|
Block* next_block = b->next;
|
||||||
|
space_allocated += (b->size);
|
||||||
|
|
||||||
|
#ifdef ADDRESS_SANITIZER
|
||||||
|
// This memory was provided by the underlying allocator as unpoisoned, so
|
||||||
|
// return it in an unpoisoned state.
|
||||||
|
ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size);
|
||||||
|
#endif // ADDRESS_SANITIZER
|
||||||
|
|
||||||
|
if (b != initial_block_) {
|
||||||
options_.block_dealloc(b, b->size);
|
options_.block_dealloc(b, b->size);
|
||||||
} else {
|
|
||||||
// User passed in the first block, skip free'ing the memory.
|
|
||||||
first_block = b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b = next_block;
|
||||||
}
|
}
|
||||||
b = next;
|
info = next_info;
|
||||||
}
|
|
||||||
blocks_ = 0;
|
|
||||||
hint_ = 0;
|
|
||||||
if (!owns_first_block_) {
|
|
||||||
// Make the first block that was passed in through ArenaOptions
|
|
||||||
// available for reuse.
|
|
||||||
first_block->pos = kHeaderSize;
|
|
||||||
// Thread which calls Reset() owns the first block. This allows the
|
|
||||||
// single-threaded case to allocate on the first block without taking any
|
|
||||||
// locks.
|
|
||||||
first_block->owner = &thread_cache();
|
|
||||||
SetThreadCacheBlock(first_block);
|
|
||||||
AddBlockInternal(first_block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return space_allocated;
|
return space_allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arena::CleanupList() {
|
void ArenaImpl::CleanupList() {
|
||||||
Node* head =
|
// By omitting an Acquire barrier we ensure that any user code that doesn't
|
||||||
reinterpret_cast<Node*>(google::protobuf::internal::NoBarrier_Load(&cleanup_list_));
|
// properly synchronize Reset() or the destructor will throw a TSAN warning.
|
||||||
while (head != NULL) {
|
ThreadInfo* info =
|
||||||
head->cleanup(head->elem);
|
reinterpret_cast<ThreadInfo*>(google::protobuf::internal::NoBarrier_Load(&threads_));
|
||||||
head = head->next;
|
|
||||||
|
for ( ; info; info = info->next) {
|
||||||
|
CleanupChunk* list = info->cleanup;
|
||||||
|
while (list) {
|
||||||
|
size_t n = list->len;
|
||||||
|
CleanupNode* node = &list->nodes[list->len - 1];
|
||||||
|
for (size_t i = 0; i < n; i++, node--) {
|
||||||
|
node->cleanup(node->elem);
|
||||||
|
}
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cleanup_list_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena::Block* Arena::FindBlock(void* me) {
|
ArenaImpl::ThreadInfo* ArenaImpl::NewThreadInfo(Block* b) {
|
||||||
// TODO(sanjay): We might want to keep a separate list with one
|
GOOGLE_DCHECK(FindThreadInfo(b->owner) == NULL);
|
||||||
// entry per thread.
|
ThreadInfo* info =
|
||||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&blocks_));
|
reinterpret_cast<ThreadInfo*>(AllocFromBlock(b, sizeof(ThreadInfo)));
|
||||||
while (b != NULL && b->owner != me) {
|
b->thread_info = info;
|
||||||
b = b->next;
|
info->owner = b->owner;
|
||||||
|
info->head = b;
|
||||||
|
info->cleanup = NULL;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaImpl::ThreadInfo* ArenaImpl::FindThreadInfo(void* me) {
|
||||||
|
ThreadInfo* info =
|
||||||
|
reinterpret_cast<ThreadInfo*>(google::protobuf::internal::Acquire_Load(&threads_));
|
||||||
|
for ( ; info; info = info->next) {
|
||||||
|
if (info->owner == me) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaImpl::ThreadInfo* ArenaImpl::GetThreadInfo(void* me, size_t n) {
|
||||||
|
ThreadInfo* info = FindThreadInfo(me);
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
// This thread doesn't have any ThreadInfo, which also means it doesn't have
|
||||||
|
// any blocks yet. So we'll allocate its first block now.
|
||||||
|
Block* b = NewBlock(me, NULL, sizeof(ThreadInfo) + n);
|
||||||
|
info = NewThreadInfo(b);
|
||||||
|
|
||||||
|
google::protobuf::internal::AtomicWord head;
|
||||||
|
do {
|
||||||
|
head = google::protobuf::internal::NoBarrier_Load(&threads_);
|
||||||
|
info->next = reinterpret_cast<ThreadInfo*>(head);
|
||||||
|
} while (google::protobuf::internal::Release_CompareAndSwap(
|
||||||
|
&threads_, head, reinterpret_cast<google::protobuf::internal::AtomicWord>(info)) != head);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
void Arena::CallDestructorHooks() {
|
||||||
|
uint64 space_allocated = impl_.SpaceAllocated();
|
||||||
|
// Call the reset hook
|
||||||
|
if (on_arena_reset_ != NULL) {
|
||||||
|
on_arena_reset_(this, hooks_cookie_, space_allocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the destruction hook
|
||||||
|
if (on_arena_destruction_ != NULL) {
|
||||||
|
on_arena_destruction_(this, hooks_cookie_, space_allocated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arena::OnArenaAllocation(const std::type_info* allocated_type,
|
||||||
|
size_t n) const {
|
||||||
|
if (on_arena_allocation_ != NULL) {
|
||||||
|
on_arena_allocation_(allocated_type, n, hooks_cookie_);
|
||||||
}
|
}
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|||||||
+353
-349
File diff suppressed because it is too large
Load Diff
+242
@@ -0,0 +1,242 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
// This file defines an Arena allocator for better allocation performance.
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
||||||
|
#define GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/atomic_sequence_num.h>
|
||||||
|
#include <google/protobuf/stubs/atomicops.h>
|
||||||
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/stubs/logging.h>
|
||||||
|
#include <google/protobuf/stubs/mutex.h>
|
||||||
|
#include <google/protobuf/stubs/type_traits.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
inline size_t AlignUpTo8(size_t n) {
|
||||||
|
// Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)
|
||||||
|
return (n + 7) & -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This class provides the core Arena memory allocation library. Different
|
||||||
|
// implementations only need to implement the public interface below.
|
||||||
|
// Arena is not a template type as that would only be useful if all protos
|
||||||
|
// in turn would be templates, which will/cannot happen. However separating
|
||||||
|
// the memory allocation part from the cruft of the API users expect we can
|
||||||
|
// use #ifdef the select the best implementation based on hardware / OS.
|
||||||
|
class LIBPROTOBUF_EXPORT ArenaImpl {
|
||||||
|
public:
|
||||||
|
struct Options {
|
||||||
|
size_t start_block_size;
|
||||||
|
size_t max_block_size;
|
||||||
|
char* initial_block;
|
||||||
|
size_t initial_block_size;
|
||||||
|
void* (*block_alloc)(size_t);
|
||||||
|
void (*block_dealloc)(void*, size_t);
|
||||||
|
|
||||||
|
template <typename O>
|
||||||
|
explicit Options(const O& options)
|
||||||
|
: start_block_size(options.start_block_size),
|
||||||
|
max_block_size(options.max_block_size),
|
||||||
|
initial_block(options.initial_block),
|
||||||
|
initial_block_size(options.initial_block_size),
|
||||||
|
block_alloc(options.block_alloc),
|
||||||
|
block_dealloc(options.block_dealloc) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename O>
|
||||||
|
explicit ArenaImpl(const O& options) : options_(options) {
|
||||||
|
if (options_.initial_block != NULL && options_.initial_block_size > 0) {
|
||||||
|
GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block))
|
||||||
|
<< ": Initial block size too small for header.";
|
||||||
|
initial_block_ = reinterpret_cast<Block*>(options_.initial_block);
|
||||||
|
} else {
|
||||||
|
initial_block_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor deletes all owned heap allocated objects, and destructs objects
|
||||||
|
// that have non-trivial destructors, except for proto2 message objects whose
|
||||||
|
// destructors can be skipped. Also, frees all blocks except the initial block
|
||||||
|
// if it was passed in.
|
||||||
|
~ArenaImpl();
|
||||||
|
|
||||||
|
uint64 Reset();
|
||||||
|
|
||||||
|
uint64 SpaceAllocated() const;
|
||||||
|
uint64 SpaceUsed() const;
|
||||||
|
|
||||||
|
void* AllocateAligned(size_t n);
|
||||||
|
|
||||||
|
void* AllocateAlignedAndAddCleanup(size_t n, void (*cleanup)(void*));
|
||||||
|
|
||||||
|
// Add object pointer and cleanup function pointer to the list.
|
||||||
|
void AddCleanup(void* elem, void (*cleanup)(void*));
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Node contains the ptr of the object to be cleaned up and the associated
|
||||||
|
// cleanup function ptr.
|
||||||
|
struct CleanupNode {
|
||||||
|
void* elem; // Pointer to the object to be cleaned up.
|
||||||
|
void (*cleanup)(void*); // Function pointer to the destructor or deleter.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cleanup uses a chunked linked list, to reduce pointer chasing.
|
||||||
|
struct CleanupChunk {
|
||||||
|
static size_t SizeOf(size_t i) {
|
||||||
|
return sizeof(CleanupChunk) + (sizeof(CleanupNode) * (i - 1));
|
||||||
|
}
|
||||||
|
size_t len; // Number of elements currently present.
|
||||||
|
size_t size; // Total elements in the list.
|
||||||
|
CleanupChunk* next; // Next node in the list.
|
||||||
|
CleanupNode nodes[1]; // True length is |size|.
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Block;
|
||||||
|
|
||||||
|
// Tracks per-thread info. ThreadInfos are kept in a linked list.
|
||||||
|
struct ThreadInfo {
|
||||||
|
void *owner; // &ThreadCache of this thread;
|
||||||
|
Block* head; // Head of linked list of blocks.
|
||||||
|
CleanupChunk* cleanup; // Head of cleanup list.
|
||||||
|
ThreadInfo* next; // Next ThreadInfo in this linked list.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Blocks are variable length malloc-ed objects. The following structure
|
||||||
|
// describes the common header for all blocks.
|
||||||
|
struct Block {
|
||||||
|
void* owner; // &ThreadCache of thread that owns this block.
|
||||||
|
ThreadInfo* thread_info; // ThreadInfo of thread that owns this block.
|
||||||
|
Block* next; // Next block in arena (may have different owner)
|
||||||
|
// ((char*) &block) + pos is next available byte. It is always
|
||||||
|
// aligned at a multiple of 8 bytes.
|
||||||
|
size_t pos;
|
||||||
|
size_t size; // total size of the block.
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
size_t avail() const { return size - pos; }
|
||||||
|
// data follows
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ThreadCache {
|
||||||
|
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
||||||
|
// If we are using the ThreadLocalStorage class to store the ThreadCache,
|
||||||
|
// then the ThreadCache's default constructor has to be responsible for
|
||||||
|
// initializing it.
|
||||||
|
ThreadCache() : last_lifecycle_id_seen(-1), last_block_used_(NULL) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The ThreadCache is considered valid as long as this matches the
|
||||||
|
// lifecycle_id of the arena being used.
|
||||||
|
int64 last_lifecycle_id_seen;
|
||||||
|
Block* last_block_used_;
|
||||||
|
};
|
||||||
|
static google::protobuf::internal::SequenceNumber lifecycle_id_generator_;
|
||||||
|
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
||||||
|
// Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread
|
||||||
|
// local storage class we implemented.
|
||||||
|
// iOS also does not support the GOOGLE_THREAD_LOCAL keyword.
|
||||||
|
static ThreadCache& thread_cache();
|
||||||
|
#elif defined(PROTOBUF_USE_DLLS)
|
||||||
|
// Thread local variables cannot be exposed through DLL interface but we can
|
||||||
|
// wrap them in static functions.
|
||||||
|
static ThreadCache& thread_cache();
|
||||||
|
#else
|
||||||
|
static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_;
|
||||||
|
static ThreadCache& thread_cache() { return thread_cache_; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
// Free all blocks and return the total space used which is the sums of sizes
|
||||||
|
// of the all the allocated blocks.
|
||||||
|
uint64 FreeBlocks();
|
||||||
|
|
||||||
|
void AddCleanupInBlock(Block* b, void* elem, void (*func)(void*));
|
||||||
|
CleanupChunk* ExpandCleanupList(CleanupChunk* cleanup, Block* b);
|
||||||
|
// Delete or Destruct all objects owned by the arena.
|
||||||
|
void CleanupList();
|
||||||
|
|
||||||
|
inline void CacheBlock(Block* block) {
|
||||||
|
thread_cache().last_block_used_ = block;
|
||||||
|
thread_cache().last_lifecycle_id_seen = lifecycle_id_;
|
||||||
|
// TODO(haberman): evaluate whether we would gain efficiency by getting rid
|
||||||
|
// of hint_. It's the only write we do to ArenaImpl in the allocation path,
|
||||||
|
// which will dirty the cache line.
|
||||||
|
google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(block));
|
||||||
|
}
|
||||||
|
|
||||||
|
google::protobuf::internal::AtomicWord threads_; // Pointer to a linked list of ThreadInfo.
|
||||||
|
google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
|
||||||
|
google::protobuf::internal::AtomicWord space_allocated_; // Sum of sizes of all allocated blocks.
|
||||||
|
|
||||||
|
Block *initial_block_; // If non-NULL, points to the block that came from
|
||||||
|
// user data.
|
||||||
|
|
||||||
|
// Returns a block owned by this thread.
|
||||||
|
Block* GetBlock(size_t n);
|
||||||
|
Block* GetBlockSlow(void* me, Block* my_full_block, size_t n);
|
||||||
|
Block* NewBlock(void* me, Block* my_last_block, size_t min_bytes);
|
||||||
|
void InitBlock(Block* b, void *me, size_t size);
|
||||||
|
static void* AllocFromBlock(Block* b, size_t n);
|
||||||
|
ThreadInfo* NewThreadInfo(Block* b);
|
||||||
|
ThreadInfo* FindThreadInfo(void* me);
|
||||||
|
ThreadInfo* GetThreadInfo(void* me, size_t n);
|
||||||
|
|
||||||
|
int64 lifecycle_id_; // Unique for each arena. Changes on Reset().
|
||||||
|
|
||||||
|
Options options_;
|
||||||
|
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArenaImpl);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// kHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8 to
|
||||||
|
// protect the invariant that pos is always at a multiple of 8.
|
||||||
|
static const size_t kHeaderSize = (sizeof(Block) + 7) & -8;
|
||||||
|
#if LANG_CXX11
|
||||||
|
static_assert(kHeaderSize % 8 == 0, "kHeaderSize must be a multiple of 8.");
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
#endif // GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
||||||
@@ -38,16 +38,6 @@ namespace protobuf {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value,
|
|
||||||
ArenaStringPtr value) {
|
|
||||||
const ::std::string* me = *UnsafeRawStringPointer();
|
|
||||||
const ::std::string* other = *value.UnsafeRawStringPointer();
|
|
||||||
// If the pointers are the same then do nothing.
|
|
||||||
if (me != other) {
|
|
||||||
SetNoArena(default_value, value.GetNoArena(default_value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|||||||
+55
-31
@@ -33,13 +33,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <google/protobuf/stubs/logging.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/fastmem.h>
|
#include <google/protobuf/stubs/fastmem.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/stubs/logging.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This is the implementation of arena string fields written for the open-source
|
// This is the implementation of arena string fields written for the open-source
|
||||||
// release. The ArenaStringPtr struct below is an internal implementation class
|
// release. The ArenaStringPtr struct below is an internal implementation class
|
||||||
@@ -63,11 +61,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic accessors.
|
inline void SetLite(const ::std::string* default_value,
|
||||||
inline const ::std::string& Get(const ::std::string* /* default_value */) const {
|
const ::std::string& value,
|
||||||
return *ptr_;
|
::google::protobuf::Arena* arena) {
|
||||||
|
Set(default_value, value, arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Basic accessors.
|
||||||
|
inline const ::std::string& Get() const { return *ptr_; }
|
||||||
|
|
||||||
inline ::std::string* Mutable(const ::std::string* default_value,
|
inline ::std::string* Mutable(const ::std::string* default_value,
|
||||||
::google::protobuf::Arena* arena) {
|
::google::protobuf::Arena* arena) {
|
||||||
if (ptr_ == default_value) {
|
if (ptr_ == default_value) {
|
||||||
@@ -87,8 +89,9 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
}
|
}
|
||||||
::std::string* released = NULL;
|
::std::string* released = NULL;
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
// ptr_ is owned by the arena -- we need to return a copy.
|
// ptr_ is owned by the arena.
|
||||||
released = new ::std::string(*ptr_);
|
released = new ::std::string;
|
||||||
|
released->swap(*ptr_);
|
||||||
} else {
|
} else {
|
||||||
released = ptr_;
|
released = ptr_;
|
||||||
}
|
}
|
||||||
@@ -146,17 +149,16 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
// Swaps internal pointers. Arena-safety semantics: this is guarded by the
|
// Swaps internal pointers. Arena-safety semantics: this is guarded by the
|
||||||
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
|
// logic in Swap()/UnsafeArenaSwap() at the message level, so this method is
|
||||||
// 'unsafe' if called directly.
|
// 'unsafe' if called directly.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) {
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) {
|
||||||
std::swap(ptr_, other->ptr_);
|
std::swap(ptr_, other->ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Frees storage (if not on an arena) and sets field to default value.
|
// Frees storage (if not on an arena).
|
||||||
inline void Destroy(const ::std::string* default_value,
|
inline void Destroy(const ::std::string* default_value,
|
||||||
::google::protobuf::Arena* arena) {
|
::google::protobuf::Arena* arena) {
|
||||||
if (arena == NULL && ptr_ != default_value) {
|
if (arena == NULL && ptr_ != default_value) {
|
||||||
delete ptr_;
|
delete ptr_;
|
||||||
}
|
}
|
||||||
ptr_ = const_cast< ::std::string* >(default_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears content, but keeps allocated string if arena != NULL, to avoid the
|
// Clears content, but keeps allocated string if arena != NULL, to avoid the
|
||||||
@@ -214,11 +216,19 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
void SetNoArena(const ::std::string* default_value, ::std::string&& value) {
|
||||||
|
if (IsDefault(default_value)) {
|
||||||
|
ptr_ = new ::std::string(std::move(value));
|
||||||
|
} else {
|
||||||
|
*ptr_ = std::move(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);
|
void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);
|
||||||
|
|
||||||
inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const {
|
inline const ::std::string& GetNoArena() const { return *ptr_; }
|
||||||
return *ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::std::string* MutableNoArena(const ::std::string* default_value) {
|
inline ::std::string* MutableNoArena(const ::std::string* default_value) {
|
||||||
if (ptr_ == default_value) {
|
if (ptr_ == default_value) {
|
||||||
@@ -253,7 +263,6 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
if (ptr_ != default_value) {
|
if (ptr_ != default_value) {
|
||||||
delete ptr_;
|
delete ptr_;
|
||||||
}
|
}
|
||||||
ptr_ = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ClearToEmptyNoArena(const ::std::string* default_value) {
|
inline void ClearToEmptyNoArena(const ::std::string* default_value) {
|
||||||
@@ -281,27 +290,26 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
return &ptr_;
|
return &ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsDefault(const ::std::string* default_value) const {
|
||||||
|
return ptr_ == default_value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::std::string* ptr_;
|
::std::string* ptr_;
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena,
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
const ::std::string* initial_value) {
|
void CreateInstance(::google::protobuf::Arena* arena,
|
||||||
// Assumes ptr_ is not NULL.
|
const ::std::string* initial_value) {
|
||||||
if (initial_value != NULL) {
|
GOOGLE_DCHECK(initial_value != NULL);
|
||||||
ptr_ = new ::std::string(*initial_value);
|
ptr_ = new ::std::string(*initial_value);
|
||||||
} else {
|
|
||||||
ptr_ = new ::std::string();
|
|
||||||
}
|
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
arena->Own(ptr_);
|
arena->Own(ptr_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) {
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
if (initial_value != NULL) {
|
void CreateInstanceNoArena(const ::std::string* initial_value) {
|
||||||
ptr_ = new ::std::string(*initial_value);
|
GOOGLE_DCHECK(initial_value != NULL);
|
||||||
} else {
|
ptr_ = new ::std::string(*initial_value);
|
||||||
ptr_ = new ::std::string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -310,5 +318,21 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
inline void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value,
|
||||||
|
ArenaStringPtr value) {
|
||||||
|
const ::std::string* me = *UnsafeRawStringPointer();
|
||||||
|
const ::std::string* other = *value.UnsafeRawStringPointer();
|
||||||
|
// If the pointers are the same then do nothing.
|
||||||
|
if (me != other) {
|
||||||
|
SetNoArena(default_value, value.GetNoArena());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
#endif // GOOGLE_PROTOBUF_ARENASTRING_H__
|
#endif // GOOGLE_PROTOBUF_ARENASTRING_H__
|
||||||
|
|||||||
+1023
-357
File diff suppressed because it is too large
Load Diff
+265
-52
@@ -62,6 +62,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/stubs/mutex.h>
|
||||||
|
#include <google/protobuf/stubs/once.h>
|
||||||
|
|
||||||
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
|
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
|
||||||
#ifdef TYPE_BOOL
|
#ifdef TYPE_BOOL
|
||||||
@@ -97,6 +99,7 @@ class FieldOptions;
|
|||||||
class OneofOptions;
|
class OneofOptions;
|
||||||
class EnumOptions;
|
class EnumOptions;
|
||||||
class EnumValueOptions;
|
class EnumValueOptions;
|
||||||
|
class ExtensionRangeOptions;
|
||||||
class ServiceOptions;
|
class ServiceOptions;
|
||||||
class MethodOptions;
|
class MethodOptions;
|
||||||
class FileOptions;
|
class FileOptions;
|
||||||
@@ -109,6 +112,7 @@ class Message;
|
|||||||
// Defined in descriptor.cc
|
// Defined in descriptor.cc
|
||||||
class DescriptorBuilder;
|
class DescriptorBuilder;
|
||||||
class FileDescriptorTables;
|
class FileDescriptorTables;
|
||||||
|
struct Symbol;
|
||||||
|
|
||||||
// Defined in unknown_field_set.h.
|
// Defined in unknown_field_set.h.
|
||||||
class UnknownField;
|
class UnknownField;
|
||||||
@@ -164,6 +168,55 @@ struct DebugStringOptions {
|
|||||||
elide_oneof_body(false) {}
|
elide_oneof_body(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A class to handle the simplest cases of a lazily linked descriptor
|
||||||
|
// for a message type that isn't built at the time of cross linking,
|
||||||
|
// which is needed when a pool has lazily_build_dependencies_ set.
|
||||||
|
// Must be instantiated as mutable in a descriptor.
|
||||||
|
namespace internal {
|
||||||
|
class LIBPROTOBUF_EXPORT LazyDescriptor {
|
||||||
|
public:
|
||||||
|
// Init function to be called at init time of a descriptor containing
|
||||||
|
// a LazyDescriptor.
|
||||||
|
void Init() {
|
||||||
|
descriptor_ = NULL;
|
||||||
|
name_ = NULL;
|
||||||
|
once_ = NULL;
|
||||||
|
file_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the value of the descriptor if it is known during the descriptor
|
||||||
|
// building process. Not thread safe, should only be called during the
|
||||||
|
// descriptor build process. Should not be called after SetLazy has been
|
||||||
|
// called.
|
||||||
|
void Set(const Descriptor* descriptor);
|
||||||
|
|
||||||
|
// Sets the information needed to lazily cross link the descriptor at a later
|
||||||
|
// time, SetLazy is not thread safe, should be called only once at descriptor
|
||||||
|
// build time if the symbol wasn't found and building of the file containing
|
||||||
|
// that type is delayed because lazily_build_dependencies_ is set on the pool.
|
||||||
|
// Should not be called after Set() has been called.
|
||||||
|
void SetLazy(const string& name, const FileDescriptor* file);
|
||||||
|
|
||||||
|
// Returns the current value of the descriptor, thread-safe. If SetLazy(...)
|
||||||
|
// has been called, will do a one-time cross link of the type specified,
|
||||||
|
// building the descriptor file that contains the type if necessary.
|
||||||
|
inline const Descriptor* Get() {
|
||||||
|
Once();
|
||||||
|
return descriptor_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void OnceStatic(LazyDescriptor* lazy);
|
||||||
|
void OnceInternal();
|
||||||
|
void Once();
|
||||||
|
|
||||||
|
const Descriptor* descriptor_;
|
||||||
|
const string* name_;
|
||||||
|
GoogleOnceDynamic* once_;
|
||||||
|
const FileDescriptor* file_;
|
||||||
|
};
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
// Describes a type of protocol message, or a particular group within a
|
// Describes a type of protocol message, or a particular group within a
|
||||||
// message. To obtain the Descriptor for a given message object, call
|
// message. To obtain the Descriptor for a given message object, call
|
||||||
// Message::GetDescriptor(). Generated message classes also have a
|
// Message::GetDescriptor(). Generated message classes also have a
|
||||||
@@ -285,8 +338,12 @@ class LIBPROTOBUF_EXPORT Descriptor {
|
|||||||
// A range of field numbers which are designated for third-party
|
// A range of field numbers which are designated for third-party
|
||||||
// extensions.
|
// extensions.
|
||||||
struct ExtensionRange {
|
struct ExtensionRange {
|
||||||
|
typedef ExtensionRangeOptions OptionsType;
|
||||||
|
|
||||||
int start; // inclusive
|
int start; // inclusive
|
||||||
int end; // exclusive
|
int end; // exclusive
|
||||||
|
|
||||||
|
const ExtensionRangeOptions* options_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The number of extension ranges in this message type.
|
// The number of extension ranges in this message type.
|
||||||
@@ -388,27 +445,30 @@ class LIBPROTOBUF_EXPORT Descriptor {
|
|||||||
const Descriptor* containing_type_;
|
const Descriptor* containing_type_;
|
||||||
const MessageOptions* options_;
|
const MessageOptions* options_;
|
||||||
|
|
||||||
|
// These arrays are separated from their sizes to minimize padding on 64-bit.
|
||||||
|
FieldDescriptor* fields_;
|
||||||
|
OneofDescriptor* oneof_decls_;
|
||||||
|
Descriptor* nested_types_;
|
||||||
|
EnumDescriptor* enum_types_;
|
||||||
|
ExtensionRange* extension_ranges_;
|
||||||
|
FieldDescriptor* extensions_;
|
||||||
|
ReservedRange* reserved_ranges_;
|
||||||
|
const string** reserved_names_;
|
||||||
|
|
||||||
|
int field_count_;
|
||||||
|
int oneof_decl_count_;
|
||||||
|
int nested_type_count_;
|
||||||
|
int enum_type_count_;
|
||||||
|
int extension_range_count_;
|
||||||
|
int extension_count_;
|
||||||
|
int reserved_range_count_;
|
||||||
|
int reserved_name_count_;
|
||||||
|
|
||||||
// True if this is a placeholder for an unknown type.
|
// True if this is a placeholder for an unknown type.
|
||||||
bool is_placeholder_;
|
bool is_placeholder_;
|
||||||
// True if this is a placeholder and the type name wasn't fully-qualified.
|
// True if this is a placeholder and the type name wasn't fully-qualified.
|
||||||
bool is_unqualified_placeholder_;
|
bool is_unqualified_placeholder_;
|
||||||
|
|
||||||
int field_count_;
|
|
||||||
FieldDescriptor* fields_;
|
|
||||||
int oneof_decl_count_;
|
|
||||||
OneofDescriptor* oneof_decls_;
|
|
||||||
int nested_type_count_;
|
|
||||||
Descriptor* nested_types_;
|
|
||||||
int enum_type_count_;
|
|
||||||
EnumDescriptor* enum_types_;
|
|
||||||
int extension_range_count_;
|
|
||||||
ExtensionRange* extension_ranges_;
|
|
||||||
int extension_count_;
|
|
||||||
FieldDescriptor* extensions_;
|
|
||||||
int reserved_range_count_;
|
|
||||||
ReservedRange* reserved_ranges_;
|
|
||||||
int reserved_name_count_;
|
|
||||||
const string** reserved_names_;
|
|
||||||
// IMPORTANT: If you add a new field, make sure to search for all instances
|
// IMPORTANT: If you add a new field, make sure to search for all instances
|
||||||
// of Allocate<Descriptor>() and AllocateArray<Descriptor>() in descriptor.cc
|
// of Allocate<Descriptor>() and AllocateArray<Descriptor>() in descriptor.cc
|
||||||
// and update them to initialize the field.
|
// and update them to initialize the field.
|
||||||
@@ -416,6 +476,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
|
|||||||
// Must be constructed using DescriptorPool.
|
// Must be constructed using DescriptorPool.
|
||||||
Descriptor() {}
|
Descriptor() {}
|
||||||
friend class DescriptorBuilder;
|
friend class DescriptorBuilder;
|
||||||
|
friend class DescriptorPool;
|
||||||
friend class EnumDescriptor;
|
friend class EnumDescriptor;
|
||||||
friend class FieldDescriptor;
|
friend class FieldDescriptor;
|
||||||
friend class OneofDescriptor;
|
friend class OneofDescriptor;
|
||||||
@@ -424,6 +485,7 @@ class LIBPROTOBUF_EXPORT Descriptor {
|
|||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Describes a single field of a message. To get the descriptor for a given
|
// Describes a single field of a message. To get the descriptor for a given
|
||||||
// field, first get the Descriptor for the message in which it is defined,
|
// field, first get the Descriptor for the message in which it is defined,
|
||||||
// then call Descriptor::FindFieldByName(). To get a FieldDescriptor for
|
// then call Descriptor::FindFieldByName(). To get a FieldDescriptor for
|
||||||
@@ -679,33 +741,41 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
|
|||||||
// to this descriptor from the file root.
|
// to this descriptor from the file root.
|
||||||
void GetLocationPath(std::vector<int>* output) const;
|
void GetLocationPath(std::vector<int>* output) const;
|
||||||
|
|
||||||
|
// Returns true if this is a map message type.
|
||||||
|
bool is_map_message_type() const;
|
||||||
|
|
||||||
const string* name_;
|
const string* name_;
|
||||||
const string* full_name_;
|
const string* full_name_;
|
||||||
const string* lowercase_name_;
|
const string* lowercase_name_;
|
||||||
const string* camelcase_name_;
|
const string* camelcase_name_;
|
||||||
// Whether the user has specified the json_name field option in the .proto
|
|
||||||
// file.
|
|
||||||
bool has_json_name_;
|
|
||||||
// If has_json_name_ is true, it's the value specified by the user.
|
// If has_json_name_ is true, it's the value specified by the user.
|
||||||
// Otherwise, it has the same value as camelcase_name_.
|
// Otherwise, it has the same value as camelcase_name_.
|
||||||
const string* json_name_;
|
const string* json_name_;
|
||||||
const FileDescriptor* file_;
|
const FileDescriptor* file_;
|
||||||
int number_;
|
GoogleOnceDynamic* type_once_;
|
||||||
Type type_;
|
static void TypeOnceInit(const FieldDescriptor* to_init);
|
||||||
|
void InternalTypeOnceInit() const;
|
||||||
|
mutable Type type_;
|
||||||
Label label_;
|
Label label_;
|
||||||
|
bool has_default_value_;
|
||||||
|
// Whether the user has specified the json_name field option in the .proto
|
||||||
|
// file.
|
||||||
|
bool has_json_name_;
|
||||||
bool is_extension_;
|
bool is_extension_;
|
||||||
|
int number_;
|
||||||
int index_in_oneof_;
|
int index_in_oneof_;
|
||||||
const Descriptor* containing_type_;
|
const Descriptor* containing_type_;
|
||||||
const OneofDescriptor* containing_oneof_;
|
const OneofDescriptor* containing_oneof_;
|
||||||
const Descriptor* extension_scope_;
|
const Descriptor* extension_scope_;
|
||||||
const Descriptor* message_type_;
|
mutable const Descriptor* message_type_;
|
||||||
const EnumDescriptor* enum_type_;
|
mutable const EnumDescriptor* enum_type_;
|
||||||
const FieldOptions* options_;
|
const FieldOptions* options_;
|
||||||
|
const string* type_name_;
|
||||||
|
const string* default_value_enum_name_;
|
||||||
// IMPORTANT: If you add a new field, make sure to search for all instances
|
// IMPORTANT: If you add a new field, make sure to search for all instances
|
||||||
// of Allocate<FieldDescriptor>() and AllocateArray<FieldDescriptor>() in
|
// of Allocate<FieldDescriptor>() and AllocateArray<FieldDescriptor>() in
|
||||||
// descriptor.cc and update them to initialize the field.
|
// descriptor.cc and update them to initialize the field.
|
||||||
|
|
||||||
bool has_default_value_;
|
|
||||||
union {
|
union {
|
||||||
int32 default_value_int32_;
|
int32 default_value_int32_;
|
||||||
int64 default_value_int64_;
|
int64 default_value_int64_;
|
||||||
@@ -715,7 +785,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
|
|||||||
double default_value_double_;
|
double default_value_double_;
|
||||||
bool default_value_bool_;
|
bool default_value_bool_;
|
||||||
|
|
||||||
const EnumValueDescriptor* default_value_enum_;
|
mutable const EnumValueDescriptor* default_value_enum_;
|
||||||
const string* default_value_string_;
|
const string* default_value_string_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -736,6 +806,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptor {
|
|||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Describes a oneof defined in a message type.
|
// Describes a oneof defined in a message type.
|
||||||
class LIBPROTOBUF_EXPORT OneofDescriptor {
|
class LIBPROTOBUF_EXPORT OneofDescriptor {
|
||||||
public:
|
public:
|
||||||
@@ -745,6 +816,8 @@ class LIBPROTOBUF_EXPORT OneofDescriptor {
|
|||||||
// Index of this oneof within the message's oneof array.
|
// Index of this oneof within the message's oneof array.
|
||||||
int index() const;
|
int index() const;
|
||||||
|
|
||||||
|
// The .proto file in which this oneof was defined. Never NULL.
|
||||||
|
const FileDescriptor* file() const;
|
||||||
// The Descriptor for the message containing this oneof.
|
// The Descriptor for the message containing this oneof.
|
||||||
const Descriptor* containing_type() const;
|
const Descriptor* containing_type() const;
|
||||||
|
|
||||||
@@ -854,12 +927,42 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
|
|||||||
// See Descriptor::DebugStringWithOptions().
|
// See Descriptor::DebugStringWithOptions().
|
||||||
string DebugStringWithOptions(const DebugStringOptions& options) const;
|
string DebugStringWithOptions(const DebugStringOptions& options) const;
|
||||||
|
|
||||||
|
|
||||||
// Returns true if this is a placeholder for an unknown enum. This will
|
// Returns true if this is a placeholder for an unknown enum. This will
|
||||||
// only be the case if this descriptor comes from a DescriptorPool
|
// only be the case if this descriptor comes from a DescriptorPool
|
||||||
// with AllowUnknownDependencies() set.
|
// with AllowUnknownDependencies() set.
|
||||||
bool is_placeholder() const;
|
bool is_placeholder() const;
|
||||||
|
|
||||||
|
// Reserved fields -------------------------------------------------
|
||||||
|
|
||||||
|
// A range of reserved field numbers.
|
||||||
|
struct ReservedRange {
|
||||||
|
int start; // inclusive
|
||||||
|
int end; // inclusive
|
||||||
|
};
|
||||||
|
|
||||||
|
// The number of reserved ranges in this message type.
|
||||||
|
int reserved_range_count() const;
|
||||||
|
// Gets an reserved range by index, where 0 <= index <
|
||||||
|
// reserved_range_count(). These are returned in the order they were defined
|
||||||
|
// in the .proto file.
|
||||||
|
const EnumDescriptor::ReservedRange* reserved_range(int index) const;
|
||||||
|
|
||||||
|
// Returns true if the number is in one of the reserved ranges.
|
||||||
|
bool IsReservedNumber(int number) const;
|
||||||
|
|
||||||
|
// Returns NULL if no reserved range contains the given number.
|
||||||
|
const EnumDescriptor::ReservedRange*
|
||||||
|
FindReservedRangeContainingNumber(int number) const;
|
||||||
|
|
||||||
|
// The number of reserved field names in this message type.
|
||||||
|
int reserved_name_count() const;
|
||||||
|
|
||||||
|
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
|
||||||
|
const string& reserved_name(int index) const;
|
||||||
|
|
||||||
|
// Returns true if the field name is reserved.
|
||||||
|
bool IsReservedName(const string& name) const;
|
||||||
|
|
||||||
// Source Location ---------------------------------------------------
|
// Source Location ---------------------------------------------------
|
||||||
|
|
||||||
// Updates |*out_location| to the source location of the complete
|
// Updates |*out_location| to the source location of the complete
|
||||||
@@ -906,6 +1009,12 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
|
|||||||
|
|
||||||
int value_count_;
|
int value_count_;
|
||||||
EnumValueDescriptor* values_;
|
EnumValueDescriptor* values_;
|
||||||
|
|
||||||
|
int reserved_range_count_;
|
||||||
|
int reserved_name_count_;
|
||||||
|
EnumDescriptor::ReservedRange* reserved_ranges_;
|
||||||
|
const string** reserved_names_;
|
||||||
|
|
||||||
// IMPORTANT: If you add a new field, make sure to search for all instances
|
// IMPORTANT: If you add a new field, make sure to search for all instances
|
||||||
// of Allocate<EnumDescriptor>() and AllocateArray<EnumDescriptor>() in
|
// of Allocate<EnumDescriptor>() and AllocateArray<EnumDescriptor>() in
|
||||||
// descriptor.cc and update them to initialize the field.
|
// descriptor.cc and update them to initialize the field.
|
||||||
@@ -917,6 +1026,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptor {
|
|||||||
friend class FieldDescriptor;
|
friend class FieldDescriptor;
|
||||||
friend class EnumValueDescriptor;
|
friend class EnumValueDescriptor;
|
||||||
friend class FileDescriptor;
|
friend class FileDescriptor;
|
||||||
|
friend class DescriptorPool;
|
||||||
friend class internal::GeneratedMessageReflection;
|
friend class internal::GeneratedMessageReflection;
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor);
|
||||||
};
|
};
|
||||||
@@ -939,6 +1049,8 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
|
|||||||
// with C++ scoping rules for enums.
|
// with C++ scoping rules for enums.
|
||||||
const string& full_name() const;
|
const string& full_name() const;
|
||||||
|
|
||||||
|
// The .proto file in which this value was defined. Never NULL.
|
||||||
|
const FileDescriptor* file() const;
|
||||||
// The type of this value. Never NULL.
|
// The type of this value. Never NULL.
|
||||||
const EnumDescriptor* type() const;
|
const EnumDescriptor* type() const;
|
||||||
|
|
||||||
@@ -993,6 +1105,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptor {
|
|||||||
EnumValueDescriptor() {}
|
EnumValueDescriptor() {}
|
||||||
friend class DescriptorBuilder;
|
friend class DescriptorBuilder;
|
||||||
friend class EnumDescriptor;
|
friend class EnumDescriptor;
|
||||||
|
friend class DescriptorPool;
|
||||||
friend class FileDescriptorTables;
|
friend class FileDescriptorTables;
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
|
||||||
};
|
};
|
||||||
@@ -1062,8 +1175,8 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor {
|
|||||||
const string* full_name_;
|
const string* full_name_;
|
||||||
const FileDescriptor* file_;
|
const FileDescriptor* file_;
|
||||||
const ServiceOptions* options_;
|
const ServiceOptions* options_;
|
||||||
int method_count_;
|
|
||||||
MethodDescriptor* methods_;
|
MethodDescriptor* methods_;
|
||||||
|
int method_count_;
|
||||||
// IMPORTANT: If you add a new field, make sure to search for all instances
|
// IMPORTANT: If you add a new field, make sure to search for all instances
|
||||||
// of Allocate<ServiceDescriptor>() and AllocateArray<ServiceDescriptor>() in
|
// of Allocate<ServiceDescriptor>() and AllocateArray<ServiceDescriptor>() in
|
||||||
// descriptor.cc and update them to initialize the field.
|
// descriptor.cc and update them to initialize the field.
|
||||||
@@ -1076,6 +1189,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptor {
|
|||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Describes an individual service method. To obtain a MethodDescriptor given
|
// Describes an individual service method. To obtain a MethodDescriptor given
|
||||||
// a service, first get its ServiceDescriptor, then call
|
// a service, first get its ServiceDescriptor, then call
|
||||||
// ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your
|
// ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your
|
||||||
@@ -1089,6 +1203,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptor {
|
|||||||
// Index within the service's Descriptor.
|
// Index within the service's Descriptor.
|
||||||
int index() const;
|
int index() const;
|
||||||
|
|
||||||
|
// The .proto file in which this method was defined. Never NULL.
|
||||||
|
const FileDescriptor* file() const;
|
||||||
// Gets the service to which this method belongs. Never NULL.
|
// Gets the service to which this method belongs. Never NULL.
|
||||||
const ServiceDescriptor* service() const;
|
const ServiceDescriptor* service() const;
|
||||||
|
|
||||||
@@ -1143,8 +1259,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptor {
|
|||||||
const string* name_;
|
const string* name_;
|
||||||
const string* full_name_;
|
const string* full_name_;
|
||||||
const ServiceDescriptor* service_;
|
const ServiceDescriptor* service_;
|
||||||
const Descriptor* input_type_;
|
mutable internal::LazyDescriptor input_type_;
|
||||||
const Descriptor* output_type_;
|
mutable internal::LazyDescriptor output_type_;
|
||||||
const MethodOptions* options_;
|
const MethodOptions* options_;
|
||||||
bool client_streaming_;
|
bool client_streaming_;
|
||||||
bool server_streaming_;
|
bool server_streaming_;
|
||||||
@@ -1300,34 +1416,49 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
|
|||||||
const string* name_;
|
const string* name_;
|
||||||
const string* package_;
|
const string* package_;
|
||||||
const DescriptorPool* pool_;
|
const DescriptorPool* pool_;
|
||||||
|
GoogleOnceDynamic* dependencies_once_;
|
||||||
|
static void DependenciesOnceInit(const FileDescriptor* to_init);
|
||||||
|
void InternalDependenciesOnceInit() const;
|
||||||
|
|
||||||
|
// These are arranged to minimze padding on 64-bit.
|
||||||
int dependency_count_;
|
int dependency_count_;
|
||||||
const FileDescriptor** dependencies_;
|
|
||||||
int public_dependency_count_;
|
int public_dependency_count_;
|
||||||
int* public_dependencies_;
|
|
||||||
int weak_dependency_count_;
|
int weak_dependency_count_;
|
||||||
int* weak_dependencies_;
|
|
||||||
int message_type_count_;
|
int message_type_count_;
|
||||||
Descriptor* message_types_;
|
|
||||||
int enum_type_count_;
|
int enum_type_count_;
|
||||||
EnumDescriptor* enum_types_;
|
|
||||||
int service_count_;
|
int service_count_;
|
||||||
ServiceDescriptor* services_;
|
|
||||||
int extension_count_;
|
int extension_count_;
|
||||||
Syntax syntax_;
|
Syntax syntax_;
|
||||||
bool is_placeholder_;
|
bool is_placeholder_;
|
||||||
|
|
||||||
|
// Indicates the FileDescriptor is completed building. Used to verify
|
||||||
|
// that type accessor functions that can possibly build a dependent file
|
||||||
|
// aren't called during the process of building the file.
|
||||||
|
bool finished_building_;
|
||||||
|
|
||||||
|
mutable const FileDescriptor** dependencies_;
|
||||||
|
const string** dependencies_names_;
|
||||||
|
int* public_dependencies_;
|
||||||
|
int* weak_dependencies_;
|
||||||
|
Descriptor* message_types_;
|
||||||
|
EnumDescriptor* enum_types_;
|
||||||
|
ServiceDescriptor* services_;
|
||||||
FieldDescriptor* extensions_;
|
FieldDescriptor* extensions_;
|
||||||
const FileOptions* options_;
|
const FileOptions* options_;
|
||||||
|
|
||||||
const FileDescriptorTables* tables_;
|
const FileDescriptorTables* tables_;
|
||||||
const SourceCodeInfo* source_code_info_;
|
const SourceCodeInfo* source_code_info_;
|
||||||
|
|
||||||
// IMPORTANT: If you add a new field, make sure to search for all instances
|
// IMPORTANT: If you add a new field, make sure to search for all instances
|
||||||
// of Allocate<FileDescriptor>() and AllocateArray<FileDescriptor>() in
|
// of Allocate<FileDescriptor>() and AllocateArray<FileDescriptor>() in
|
||||||
// descriptor.cc and update them to initialize the field.
|
// descriptor.cc and update them to initialize the field.
|
||||||
|
|
||||||
FileDescriptor() {}
|
FileDescriptor() {}
|
||||||
friend class DescriptorBuilder;
|
friend class DescriptorBuilder;
|
||||||
|
friend class DescriptorPool;
|
||||||
friend class Descriptor;
|
friend class Descriptor;
|
||||||
friend class FieldDescriptor;
|
friend class FieldDescriptor;
|
||||||
|
friend class internal::LazyDescriptor;
|
||||||
friend class OneofDescriptor;
|
friend class OneofDescriptor;
|
||||||
friend class EnumDescriptor;
|
friend class EnumDescriptor;
|
||||||
friend class EnumValueDescriptor;
|
friend class EnumValueDescriptor;
|
||||||
@@ -1336,6 +1467,7 @@ class LIBPROTOBUF_EXPORT FileDescriptor {
|
|||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
// Used to construct descriptors.
|
// Used to construct descriptors.
|
||||||
@@ -1558,6 +1690,9 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
|
|||||||
static void InternalAddGeneratedFile(
|
static void InternalAddGeneratedFile(
|
||||||
const void* encoded_file_descriptor, int size);
|
const void* encoded_file_descriptor, int size);
|
||||||
|
|
||||||
|
// Disallow [enforce_utf8 = false] in .proto files.
|
||||||
|
void DisallowEnforceUtf8() { disallow_enforce_utf8_ = true; }
|
||||||
|
|
||||||
|
|
||||||
// For internal use only: Gets a non-const pointer to the generated pool.
|
// For internal use only: Gets a non-const pointer to the generated pool.
|
||||||
// This is called at static-initialization time only, so thread-safety is
|
// This is called at static-initialization time only, so thread-safety is
|
||||||
@@ -1570,6 +1705,21 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
|
|||||||
// which it did not officially declare as dependencies.
|
// which it did not officially declare as dependencies.
|
||||||
void InternalDontEnforceDependencies();
|
void InternalDontEnforceDependencies();
|
||||||
|
|
||||||
|
// For internal use only: Enables lazy building of dependencies of a file.
|
||||||
|
// Delay the building of dependencies of a file descriptor until absolutely
|
||||||
|
// necessary, like when message_type() is called on a field that is defined
|
||||||
|
// in that dependency's file. This will cause functional issues if a proto
|
||||||
|
// or one of it's dependencies has errors. Should only be enabled for the
|
||||||
|
// generated_pool_ (because no descriptor build errors are guaranteed by
|
||||||
|
// the compilation generation process), testing, or if a lack of descriptor
|
||||||
|
// build errors can be guaranteed for a pool.
|
||||||
|
void InternalSetLazilyBuildDependencies() {
|
||||||
|
lazily_build_dependencies_ = true;
|
||||||
|
// This needs to be set when lazily building dependencies, as it breaks
|
||||||
|
// dependency checking.
|
||||||
|
InternalDontEnforceDependencies();
|
||||||
|
}
|
||||||
|
|
||||||
// For internal use only.
|
// For internal use only.
|
||||||
void internal_set_underlay(const DescriptorPool* underlay) {
|
void internal_set_underlay(const DescriptorPool* underlay) {
|
||||||
underlay_ = underlay;
|
underlay_ = underlay;
|
||||||
@@ -1588,10 +1738,13 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Descriptor;
|
friend class Descriptor;
|
||||||
|
friend class internal::LazyDescriptor;
|
||||||
friend class FieldDescriptor;
|
friend class FieldDescriptor;
|
||||||
friend class EnumDescriptor;
|
friend class EnumDescriptor;
|
||||||
friend class ServiceDescriptor;
|
friend class ServiceDescriptor;
|
||||||
|
friend class MethodDescriptor;
|
||||||
friend class FileDescriptor;
|
friend class FileDescriptor;
|
||||||
|
friend class StreamDescriptor;
|
||||||
friend class DescriptorBuilder;
|
friend class DescriptorBuilder;
|
||||||
friend class FileDescriptorTables;
|
friend class FileDescriptorTables;
|
||||||
|
|
||||||
@@ -1615,6 +1768,28 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
|
|||||||
const FileDescriptor* BuildFileFromDatabase(
|
const FileDescriptor* BuildFileFromDatabase(
|
||||||
const FileDescriptorProto& proto) const;
|
const FileDescriptorProto& proto) const;
|
||||||
|
|
||||||
|
// Helper for when lazily_build_dependencies_ is set, can look up a symbol
|
||||||
|
// after the file's descriptor is built, and can build the file where that
|
||||||
|
// symbol is defined if necessary. Will create a placeholder if the type
|
||||||
|
// doesn't exist in the fallback database, or the file doesn't build
|
||||||
|
// successfully.
|
||||||
|
Symbol CrossLinkOnDemandHelper(const string& name, bool expecting_enum) const;
|
||||||
|
|
||||||
|
// Create a placeholder FileDescriptor of the specified name
|
||||||
|
FileDescriptor* NewPlaceholderFile(const string& name) const;
|
||||||
|
FileDescriptor* NewPlaceholderFileWithMutexHeld(const string& name) const;
|
||||||
|
|
||||||
|
enum PlaceholderType {
|
||||||
|
PLACEHOLDER_MESSAGE,
|
||||||
|
PLACEHOLDER_ENUM,
|
||||||
|
PLACEHOLDER_EXTENDABLE_MESSAGE
|
||||||
|
};
|
||||||
|
// Create a placeholder Descriptor of the specified name
|
||||||
|
Symbol NewPlaceholder(const string& name,
|
||||||
|
PlaceholderType placeholder_type) const;
|
||||||
|
Symbol NewPlaceholderWithMutexHeld(const string& name,
|
||||||
|
PlaceholderType placeholder_type) const;
|
||||||
|
|
||||||
// If fallback_database_ is NULL, this is NULL. Otherwise, this is a mutex
|
// If fallback_database_ is NULL, this is NULL. Otherwise, this is a mutex
|
||||||
// which must be locked while accessing tables_.
|
// which must be locked while accessing tables_.
|
||||||
Mutex* mutex_;
|
Mutex* mutex_;
|
||||||
@@ -1630,13 +1805,16 @@ class LIBPROTOBUF_EXPORT DescriptorPool {
|
|||||||
google::protobuf::scoped_ptr<Tables> tables_;
|
google::protobuf::scoped_ptr<Tables> tables_;
|
||||||
|
|
||||||
bool enforce_dependencies_;
|
bool enforce_dependencies_;
|
||||||
|
bool lazily_build_dependencies_;
|
||||||
bool allow_unknown_;
|
bool allow_unknown_;
|
||||||
bool enforce_weak_;
|
bool enforce_weak_;
|
||||||
|
bool disallow_enforce_utf8_;
|
||||||
std::set<string> unused_import_track_files_;
|
std::set<string> unused_import_track_files_;
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// inline methods ====================================================
|
// inline methods ====================================================
|
||||||
|
|
||||||
// These macros makes this repetitive code more readable.
|
// These macros makes this repetitive code more readable.
|
||||||
@@ -1692,15 +1870,12 @@ PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, camelcase_name)
|
|||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, file, const FileDescriptor*)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, file, const FileDescriptor*)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, number, int)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, number, int)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, is_extension, bool)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, is_extension, bool)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, type, FieldDescriptor::Type)
|
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, label, FieldDescriptor::Label)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, label, FieldDescriptor::Label)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_type, const Descriptor*)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_type, const Descriptor*)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_oneof,
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_oneof,
|
||||||
const OneofDescriptor*)
|
const OneofDescriptor*)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, index_in_oneof, int)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, index_in_oneof, int)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, extension_scope, const Descriptor*)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, extension_scope, const Descriptor*)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, message_type, const Descriptor*)
|
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, enum_type, const EnumDescriptor*)
|
|
||||||
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions)
|
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_json_name, bool)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_json_name, bool)
|
||||||
@@ -1711,8 +1886,6 @@ PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint64, uint64)
|
|||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_float , float )
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_float , float )
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_double, double)
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_double, double)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_bool , bool )
|
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_bool , bool )
|
||||||
PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_enum,
|
|
||||||
const EnumValueDescriptor*)
|
|
||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, default_value_string)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, default_value_string)
|
||||||
|
|
||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(OneofDescriptor, name)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(OneofDescriptor, name)
|
||||||
@@ -1730,6 +1903,10 @@ PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, value,
|
|||||||
const EnumValueDescriptor*)
|
const EnumValueDescriptor*)
|
||||||
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumDescriptor, EnumOptions)
|
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumDescriptor, EnumOptions)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, is_placeholder, bool)
|
PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, is_placeholder, bool)
|
||||||
|
PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_range_count, int)
|
||||||
|
PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, reserved_range,
|
||||||
|
const EnumDescriptor::ReservedRange*)
|
||||||
|
PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_name_count, int)
|
||||||
|
|
||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, name)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, name)
|
||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, full_name)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, full_name)
|
||||||
@@ -1748,8 +1925,6 @@ PROTOBUF_DEFINE_OPTIONS_ACCESSOR(ServiceDescriptor, ServiceOptions)
|
|||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, name)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, name)
|
||||||
PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, full_name)
|
PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, full_name)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, service, const ServiceDescriptor*)
|
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, service, const ServiceDescriptor*)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, input_type, const Descriptor*)
|
|
||||||
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, output_type, const Descriptor*)
|
|
||||||
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(MethodDescriptor, MethodOptions)
|
PROTOBUF_DEFINE_OPTIONS_ACCESSOR(MethodDescriptor, MethodOptions)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, client_streaming, bool)
|
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, client_streaming, bool)
|
||||||
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, server_streaming, bool)
|
PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, server_streaming, bool)
|
||||||
@@ -1803,6 +1978,32 @@ inline const string& Descriptor::reserved_name(int index) const {
|
|||||||
return *reserved_names_[index];
|
return *reserved_names_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool EnumDescriptor::IsReservedNumber(int number) const {
|
||||||
|
return FindReservedRangeContainingNumber(number) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool EnumDescriptor::IsReservedName(const string& name) const {
|
||||||
|
for (int i = 0; i < reserved_name_count(); i++) {
|
||||||
|
if (name == reserved_name(i)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
|
||||||
|
// an array of pointers rather than the usual array of objects.
|
||||||
|
inline const string& EnumDescriptor::reserved_name(int index) const {
|
||||||
|
return *reserved_names_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FieldDescriptor::Type FieldDescriptor::type() const {
|
||||||
|
if (type_once_) {
|
||||||
|
type_once_->Init(&FieldDescriptor::TypeOnceInit, this);
|
||||||
|
}
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool FieldDescriptor::is_required() const {
|
inline bool FieldDescriptor::is_required() const {
|
||||||
return label() == LABEL_REQUIRED;
|
return label() == LABEL_REQUIRED;
|
||||||
}
|
}
|
||||||
@@ -1819,11 +2020,15 @@ inline bool FieldDescriptor::is_packable() const {
|
|||||||
return is_repeated() && IsTypePackable(type());
|
return is_repeated() && IsTypePackable(type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool FieldDescriptor::is_map() const {
|
||||||
|
return type() == TYPE_MESSAGE && is_map_message_type();
|
||||||
|
}
|
||||||
|
|
||||||
// To save space, index() is computed by looking at the descriptor's position
|
// To save space, index() is computed by looking at the descriptor's position
|
||||||
// in the parent's array of children.
|
// in the parent's array of children.
|
||||||
inline int FieldDescriptor::index() const {
|
inline int FieldDescriptor::index() const {
|
||||||
if (!is_extension_) {
|
if (!is_extension_) {
|
||||||
return static_cast<int>(this - containing_type_->fields_);
|
return static_cast<int>(this - containing_type()->fields_);
|
||||||
} else if (extension_scope_ != NULL) {
|
} else if (extension_scope_ != NULL) {
|
||||||
return static_cast<int>(this - extension_scope_->extensions_);
|
return static_cast<int>(this - extension_scope_->extensions_);
|
||||||
} else {
|
} else {
|
||||||
@@ -1839,6 +2044,10 @@ inline int Descriptor::index() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const FileDescriptor* OneofDescriptor::file() const {
|
||||||
|
return containing_type()->file();
|
||||||
|
}
|
||||||
|
|
||||||
inline int OneofDescriptor::index() const {
|
inline int OneofDescriptor::index() const {
|
||||||
return static_cast<int>(this - containing_type_->oneof_decls_);
|
return static_cast<int>(this - containing_type_->oneof_decls_);
|
||||||
}
|
}
|
||||||
@@ -1851,6 +2060,10 @@ inline int EnumDescriptor::index() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const FileDescriptor* EnumValueDescriptor::file() const {
|
||||||
|
return type()->file();
|
||||||
|
}
|
||||||
|
|
||||||
inline int EnumValueDescriptor::index() const {
|
inline int EnumValueDescriptor::index() const {
|
||||||
return static_cast<int>(this - type_->values_);
|
return static_cast<int>(this - type_->values_);
|
||||||
}
|
}
|
||||||
@@ -1859,20 +2072,24 @@ inline int ServiceDescriptor::index() const {
|
|||||||
return static_cast<int>(this - file_->services_);
|
return static_cast<int>(this - file_->services_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const FileDescriptor* MethodDescriptor::file() const {
|
||||||
|
return service()->file();
|
||||||
|
}
|
||||||
|
|
||||||
inline int MethodDescriptor::index() const {
|
inline int MethodDescriptor::index() const {
|
||||||
return static_cast<int>(this - service_->methods_);
|
return static_cast<int>(this - service_->methods_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* FieldDescriptor::type_name() const {
|
inline const char* FieldDescriptor::type_name() const {
|
||||||
return kTypeToName[type_];
|
return kTypeToName[type()];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FieldDescriptor::CppType FieldDescriptor::cpp_type() const {
|
inline FieldDescriptor::CppType FieldDescriptor::cpp_type() const {
|
||||||
return kTypeToCppTypeMap[type_];
|
return kTypeToCppTypeMap[type()];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* FieldDescriptor::cpp_type_name() const {
|
inline const char* FieldDescriptor::cpp_type_name() const {
|
||||||
return kCppTypeToName[kTypeToCppTypeMap[type_]];
|
return kCppTypeToName[kTypeToCppTypeMap[type()]];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) {
|
inline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) {
|
||||||
@@ -1894,18 +2111,14 @@ inline bool FieldDescriptor::IsTypePackable(Type field_type) {
|
|||||||
field_type != FieldDescriptor::TYPE_BYTES);
|
field_type != FieldDescriptor::TYPE_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const FileDescriptor* FileDescriptor::dependency(int index) const {
|
|
||||||
return dependencies_[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const FileDescriptor* FileDescriptor::public_dependency(
|
inline const FileDescriptor* FileDescriptor::public_dependency(
|
||||||
int index) const {
|
int index) const {
|
||||||
return dependencies_[public_dependencies_[index]];
|
return dependency(public_dependencies_[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const FileDescriptor* FileDescriptor::weak_dependency(
|
inline const FileDescriptor* FileDescriptor::weak_dependency(
|
||||||
int index) const {
|
int index) const {
|
||||||
return dependencies_[weak_dependencies_[index]];
|
return dependency(weak_dependencies_[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FileDescriptor::Syntax FileDescriptor::syntax() const {
|
inline FileDescriptor::Syntax FileDescriptor::syntax() const {
|
||||||
|
|||||||
+8240
-10111
File diff suppressed because it is too large
Load Diff
+5136
-1851
File diff suppressed because it is too large
Load Diff
+29
-25
@@ -39,8 +39,9 @@
|
|||||||
#include <google/protobuf/descriptor.pb.h>
|
#include <google/protobuf/descriptor.pb.h>
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
#include <google/protobuf/stubs/strutil.h>
|
#include <google/protobuf/stubs/strutil.h>
|
||||||
#include <google/protobuf/stubs/stl_util.h>
|
|
||||||
#include <google/protobuf/stubs/map_util.h>
|
#include <google/protobuf/stubs/map_util.h>
|
||||||
|
#include <google/protobuf/stubs/stl_util.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
@@ -97,11 +98,12 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
|
|||||||
|
|
||||||
// Try to look up the symbol to make sure a super-symbol doesn't already
|
// Try to look up the symbol to make sure a super-symbol doesn't already
|
||||||
// exist.
|
// exist.
|
||||||
typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);
|
typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name);
|
||||||
|
|
||||||
if (iter == by_symbol_.end()) {
|
if (iter == by_symbol_.end()) {
|
||||||
// Apparently the map is currently empty. Just insert and be done with it.
|
// Apparently the map is currently empty. Just insert and be done with it.
|
||||||
by_symbol_.insert(typename map<string, Value>::value_type(name, value));
|
by_symbol_.insert(
|
||||||
|
typename std::map<string, Value>::value_type(name, value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +130,8 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
|
|||||||
|
|
||||||
// Insert the new symbol using the iterator as a hint, the new entry will
|
// Insert the new symbol using the iterator as a hint, the new entry will
|
||||||
// appear immediately before the one the iterator is pointing at.
|
// appear immediately before the one the iterator is pointing at.
|
||||||
by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value));
|
by_symbol_.insert(iter,
|
||||||
|
typename std::map<string, Value>::value_type(name, value));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -179,7 +182,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile(
|
|||||||
template <typename Value>
|
template <typename Value>
|
||||||
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(
|
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(
|
||||||
const string& name) {
|
const string& name) {
|
||||||
typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);
|
typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name);
|
||||||
|
|
||||||
return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ?
|
return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ?
|
||||||
iter->second : Value();
|
iter->second : Value();
|
||||||
@@ -196,8 +199,8 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension(
|
|||||||
template <typename Value>
|
template <typename Value>
|
||||||
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(
|
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(
|
||||||
const string& containing_type,
|
const string& containing_type,
|
||||||
vector<int>* output) {
|
std::vector<int>* output) {
|
||||||
typename map<pair<string, int>, Value>::const_iterator it =
|
typename std::map<std::pair<string, int>, Value>::const_iterator it =
|
||||||
by_extension_.lower_bound(std::make_pair(containing_type, 0));
|
by_extension_.lower_bound(std::make_pair(containing_type, 0));
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@@ -211,13 +214,14 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Value>
|
template <typename Value>
|
||||||
typename map<string, Value>::iterator
|
typename std::map<string, Value>::iterator
|
||||||
SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual(
|
SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual(
|
||||||
const string& name) {
|
const string& name) {
|
||||||
// Find the last key in the map which sorts less than or equal to the
|
// Find the last key in the map which sorts less than or equal to the
|
||||||
// symbol name. Since upper_bound() returns the *first* key that sorts
|
// symbol name. Since upper_bound() returns the *first* key that sorts
|
||||||
// *greater* than the input, we want the element immediately before that.
|
// *greater* than the input, we want the element immediately before that.
|
||||||
typename map<string, Value>::iterator iter = by_symbol_.upper_bound(name);
|
typename std::map<string, Value>::iterator iter =
|
||||||
|
by_symbol_.upper_bound(name);
|
||||||
if (iter != by_symbol_.begin()) --iter;
|
if (iter != by_symbol_.begin()) --iter;
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
@@ -227,7 +231,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::IsSubSymbol(
|
|||||||
const string& sub_symbol, const string& super_symbol) {
|
const string& sub_symbol, const string& super_symbol) {
|
||||||
return sub_symbol == super_symbol ||
|
return sub_symbol == super_symbol ||
|
||||||
(HasPrefixString(super_symbol, sub_symbol) &&
|
(HasPrefixString(super_symbol, sub_symbol) &&
|
||||||
super_symbol[sub_symbol.size()] == '.');
|
super_symbol[sub_symbol.size()] == '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Value>
|
template <typename Value>
|
||||||
@@ -284,7 +288,7 @@ bool SimpleDescriptorDatabase::FindFileContainingExtension(
|
|||||||
|
|
||||||
bool SimpleDescriptorDatabase::FindAllExtensionNumbers(
|
bool SimpleDescriptorDatabase::FindAllExtensionNumbers(
|
||||||
const string& extendee_type,
|
const string& extendee_type,
|
||||||
vector<int>* output) {
|
std::vector<int>* output) {
|
||||||
return index_.FindAllExtensionNumbers(extendee_type, output);
|
return index_.FindAllExtensionNumbers(extendee_type, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +344,7 @@ bool EncodedDescriptorDatabase::FindFileContainingSymbol(
|
|||||||
bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(
|
bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(
|
||||||
const string& symbol_name,
|
const string& symbol_name,
|
||||||
string* output) {
|
string* output) {
|
||||||
pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name);
|
std::pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name);
|
||||||
if (encoded_file.first == NULL) return false;
|
if (encoded_file.first == NULL) return false;
|
||||||
|
|
||||||
// Optimization: The name should be the first field in the encoded message.
|
// Optimization: The name should be the first field in the encoded message.
|
||||||
@@ -352,7 +356,7 @@ bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(
|
|||||||
FileDescriptorProto::kNameFieldNumber,
|
FileDescriptorProto::kNameFieldNumber,
|
||||||
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
|
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
|
||||||
|
|
||||||
if (input.ReadTag() == kNameTag) {
|
if (input.ReadTagNoLastTag() == kNameTag) {
|
||||||
// Success!
|
// Success!
|
||||||
return internal::WireFormatLite::ReadString(&input, output);
|
return internal::WireFormatLite::ReadString(&input, output);
|
||||||
} else {
|
} else {
|
||||||
@@ -376,12 +380,12 @@ bool EncodedDescriptorDatabase::FindFileContainingExtension(
|
|||||||
|
|
||||||
bool EncodedDescriptorDatabase::FindAllExtensionNumbers(
|
bool EncodedDescriptorDatabase::FindAllExtensionNumbers(
|
||||||
const string& extendee_type,
|
const string& extendee_type,
|
||||||
vector<int>* output) {
|
std::vector<int>* output) {
|
||||||
return index_.FindAllExtensionNumbers(extendee_type, output);
|
return index_.FindAllExtensionNumbers(extendee_type, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EncodedDescriptorDatabase::MaybeParse(
|
bool EncodedDescriptorDatabase::MaybeParse(
|
||||||
pair<const void*, int> encoded_file,
|
std::pair<const void*, int> encoded_file,
|
||||||
FileDescriptorProto* output) {
|
FileDescriptorProto* output) {
|
||||||
if (encoded_file.first == NULL) return false;
|
if (encoded_file.first == NULL) return false;
|
||||||
return output->ParseFromArray(encoded_file.first, encoded_file.second);
|
return output->ParseFromArray(encoded_file.first, encoded_file.second);
|
||||||
@@ -431,11 +435,11 @@ bool DescriptorPoolDatabase::FindFileContainingExtension(
|
|||||||
|
|
||||||
bool DescriptorPoolDatabase::FindAllExtensionNumbers(
|
bool DescriptorPoolDatabase::FindAllExtensionNumbers(
|
||||||
const string& extendee_type,
|
const string& extendee_type,
|
||||||
vector<int>* output) {
|
std::vector<int>* output) {
|
||||||
const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type);
|
const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type);
|
||||||
if (extendee == NULL) return false;
|
if (extendee == NULL) return false;
|
||||||
|
|
||||||
vector<const FieldDescriptor*> extensions;
|
std::vector<const FieldDescriptor*> extensions;
|
||||||
pool_.FindAllExtensions(extendee, &extensions);
|
pool_.FindAllExtensions(extendee, &extensions);
|
||||||
|
|
||||||
for (int i = 0; i < extensions.size(); ++i) {
|
for (int i = 0; i < extensions.size(); ++i) {
|
||||||
@@ -454,7 +458,7 @@ MergedDescriptorDatabase::MergedDescriptorDatabase(
|
|||||||
sources_.push_back(source2);
|
sources_.push_back(source2);
|
||||||
}
|
}
|
||||||
MergedDescriptorDatabase::MergedDescriptorDatabase(
|
MergedDescriptorDatabase::MergedDescriptorDatabase(
|
||||||
const vector<DescriptorDatabase*>& sources)
|
const std::vector<DescriptorDatabase*>& sources)
|
||||||
: sources_(sources) {}
|
: sources_(sources) {}
|
||||||
MergedDescriptorDatabase::~MergedDescriptorDatabase() {}
|
MergedDescriptorDatabase::~MergedDescriptorDatabase() {}
|
||||||
|
|
||||||
@@ -517,23 +521,23 @@ bool MergedDescriptorDatabase::FindFileContainingExtension(
|
|||||||
|
|
||||||
bool MergedDescriptorDatabase::FindAllExtensionNumbers(
|
bool MergedDescriptorDatabase::FindAllExtensionNumbers(
|
||||||
const string& extendee_type,
|
const string& extendee_type,
|
||||||
vector<int>* output) {
|
std::vector<int>* output) {
|
||||||
set<int> merged_results;
|
std::set<int> merged_results;
|
||||||
vector<int> results;
|
std::vector<int> results;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
for (int i = 0; i < sources_.size(); i++) {
|
for (int i = 0; i < sources_.size(); i++) {
|
||||||
if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) {
|
if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) {
|
||||||
std::copy(
|
std::copy(results.begin(), results.end(),
|
||||||
results.begin(), results.end(),
|
std::insert_iterator<std::set<int> >(merged_results,
|
||||||
insert_iterator<set<int> >(merged_results, merged_results.begin()));
|
merged_results.begin()));
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
results.clear();
|
results.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::copy(merged_results.begin(), merged_results.end(),
|
std::copy(merged_results.begin(), merged_results.end(),
|
||||||
insert_iterator<vector<int> >(*output, output->end()));
|
std::insert_iterator<std::vector<int> >(*output, output->end()));
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-16
@@ -97,11 +97,23 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
|
|||||||
// This method has a default implementation that always returns
|
// This method has a default implementation that always returns
|
||||||
// false.
|
// false.
|
||||||
virtual bool FindAllExtensionNumbers(const string& /* extendee_type */,
|
virtual bool FindAllExtensionNumbers(const string& /* extendee_type */,
|
||||||
vector<int>* /* output */) {
|
std::vector<int>* /* output */) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Finds the file names and appends them to the output in an
|
||||||
|
// undefined order. This method is best-effort: it's not guaranteed that the
|
||||||
|
// database will find all files. Returns true if the database supports
|
||||||
|
// searching all file names, otherwise returns false and leaves output
|
||||||
|
// unchanged.
|
||||||
|
//
|
||||||
|
// This method has a default implementation that always returns
|
||||||
|
// false.
|
||||||
|
virtual bool FindAllFileNames(std::vector<string>* output) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase);
|
||||||
};
|
};
|
||||||
@@ -150,7 +162,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
|
|||||||
int field_number,
|
int field_number,
|
||||||
FileDescriptorProto* output);
|
FileDescriptorProto* output);
|
||||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||||
vector<int>* output);
|
std::vector<int>* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// So that it can use DescriptorIndex.
|
// So that it can use DescriptorIndex.
|
||||||
@@ -175,12 +187,12 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
|
|||||||
Value FindSymbol(const string& name);
|
Value FindSymbol(const string& name);
|
||||||
Value FindExtension(const string& containing_type, int field_number);
|
Value FindExtension(const string& containing_type, int field_number);
|
||||||
bool FindAllExtensionNumbers(const string& containing_type,
|
bool FindAllExtensionNumbers(const string& containing_type,
|
||||||
vector<int>* output);
|
std::vector<int>* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
map<string, Value> by_name_;
|
std::map<string, Value> by_name_;
|
||||||
map<string, Value> by_symbol_;
|
std::map<string, Value> by_symbol_;
|
||||||
map<pair<string, int>, Value> by_extension_;
|
std::map<std::pair<string, int>, Value> by_extension_;
|
||||||
|
|
||||||
// Invariant: The by_symbol_ map does not contain any symbols which are
|
// Invariant: The by_symbol_ map does not contain any symbols which are
|
||||||
// prefixes of other symbols in the map. For example, "foo.bar" is a
|
// prefixes of other symbols in the map. For example, "foo.bar" is a
|
||||||
@@ -235,7 +247,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
|
|||||||
|
|
||||||
// Find the last entry in the by_symbol_ map whose key is less than or
|
// Find the last entry in the by_symbol_ map whose key is less than or
|
||||||
// equal to the given name.
|
// equal to the given name.
|
||||||
typename map<string, Value>::iterator FindLastLessOrEqual(
|
typename std::map<string, Value>::iterator FindLastLessOrEqual(
|
||||||
const string& name);
|
const string& name);
|
||||||
|
|
||||||
// True if either the arguments are equal or super_symbol identifies a
|
// True if either the arguments are equal or super_symbol identifies a
|
||||||
@@ -250,7 +262,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
|
|||||||
|
|
||||||
|
|
||||||
DescriptorIndex<const FileDescriptorProto*> index_;
|
DescriptorIndex<const FileDescriptorProto*> index_;
|
||||||
vector<const FileDescriptorProto*> files_to_delete_;
|
std::vector<const FileDescriptorProto*> files_to_delete_;
|
||||||
|
|
||||||
// If file is non-NULL, copy it into *output and return true, otherwise
|
// If file is non-NULL, copy it into *output and return true, otherwise
|
||||||
// return false.
|
// return false.
|
||||||
@@ -295,15 +307,16 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
|
|||||||
int field_number,
|
int field_number,
|
||||||
FileDescriptorProto* output);
|
FileDescriptorProto* output);
|
||||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||||
vector<int>* output);
|
std::vector<int>* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_;
|
SimpleDescriptorDatabase::DescriptorIndex<std::pair<const void*, int> >
|
||||||
vector<void*> files_to_delete_;
|
index_;
|
||||||
|
std::vector<void*> files_to_delete_;
|
||||||
|
|
||||||
// If encoded_file.first is non-NULL, parse the data into *output and return
|
// If encoded_file.first is non-NULL, parse the data into *output and return
|
||||||
// true, otherwise return false.
|
// true, otherwise return false.
|
||||||
bool MaybeParse(pair<const void*, int> encoded_file,
|
bool MaybeParse(std::pair<const void*, int> encoded_file,
|
||||||
FileDescriptorProto* output);
|
FileDescriptorProto* output);
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);
|
||||||
@@ -324,7 +337,7 @@ class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
|
|||||||
int field_number,
|
int field_number,
|
||||||
FileDescriptorProto* output);
|
FileDescriptorProto* output);
|
||||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||||
vector<int>* output);
|
std::vector<int>* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const DescriptorPool& pool_;
|
const DescriptorPool& pool_;
|
||||||
@@ -341,7 +354,8 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
|
|||||||
// Merge more than two databases. The sources remain property of the caller.
|
// Merge more than two databases. The sources remain property of the caller.
|
||||||
// The vector may be deleted after the constructor returns but the
|
// The vector may be deleted after the constructor returns but the
|
||||||
// DescriptorDatabases need to stick around.
|
// DescriptorDatabases need to stick around.
|
||||||
explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources);
|
explicit MergedDescriptorDatabase(
|
||||||
|
const std::vector<DescriptorDatabase*>& sources);
|
||||||
~MergedDescriptorDatabase();
|
~MergedDescriptorDatabase();
|
||||||
|
|
||||||
// implements DescriptorDatabase -----------------------------------
|
// implements DescriptorDatabase -----------------------------------
|
||||||
@@ -355,11 +369,11 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
|
|||||||
// Merges the results of calling all databases. Returns true iff any
|
// Merges the results of calling all databases. Returns true iff any
|
||||||
// of the databases returned true.
|
// of the databases returned true.
|
||||||
bool FindAllExtensionNumbers(const string& extendee_type,
|
bool FindAllExtensionNumbers(const string& extendee_type,
|
||||||
vector<int>* output);
|
std::vector<int>* output);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<DescriptorDatabase*> sources_;
|
std::vector<DescriptorDatabase*> sources_;
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+180
-227
@@ -1,7 +1,6 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: google/protobuf/duration.proto
|
// source: google/protobuf/duration.proto
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include <google/protobuf/duration.pb.h>
|
#include <google/protobuf/duration.pb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -15,118 +14,114 @@
|
|||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
|
// This is a temporary google only hack
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
#include "third_party/protobuf/version.h"
|
||||||
|
#endif
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
class DurationDefaultTypeInternal {
|
||||||
|
public:
|
||||||
|
::google::protobuf::internal::ExplicitlyConstructed<Duration>
|
||||||
|
_instance;
|
||||||
|
} _Duration_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace protobuf_google_2fprotobuf_2fduration_2eproto {
|
||||||
|
void InitDefaultsDurationImpl() {
|
||||||
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
|
||||||
|
#else
|
||||||
|
::google::protobuf::internal::InitProtobufDefaults();
|
||||||
|
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
{
|
||||||
|
void* ptr = &::google::protobuf::_Duration_default_instance_;
|
||||||
|
new (ptr) ::google::protobuf::Duration();
|
||||||
|
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
||||||
|
}
|
||||||
|
::google::protobuf::Duration::InitAsDefaultInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDefaultsDuration() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsDurationImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
::google::protobuf::Metadata file_level_metadata[1];
|
||||||
|
|
||||||
|
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
~0u, // no _has_bits_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, _internal_metadata_),
|
||||||
|
~0u, // no _extensions_
|
||||||
|
~0u, // no _oneof_case_
|
||||||
|
~0u, // no _weak_field_map_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, seconds_),
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Duration, nanos_),
|
||||||
|
};
|
||||||
|
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
{ 0, -1, sizeof(::google::protobuf::Duration)},
|
||||||
|
};
|
||||||
|
|
||||||
|
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||||
|
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Duration_default_instance_),
|
||||||
|
};
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptors() {
|
||||||
|
AddDescriptors();
|
||||||
|
::google::protobuf::MessageFactory* factory = NULL;
|
||||||
|
AssignDescriptors(
|
||||||
|
"google/protobuf/duration.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||||
|
file_level_metadata, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptorsOnce() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) {
|
||||||
|
protobuf_AssignDescriptorsOnce();
|
||||||
|
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptorsImpl() {
|
||||||
|
InitDefaults();
|
||||||
|
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
"\n\036google/protobuf/duration.proto\022\017google"
|
||||||
|
".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
|
||||||
|
"\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu"
|
||||||
|
"rationProtoP\001Z*github.com/golang/protobu"
|
||||||
|
"f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot"
|
||||||
|
"obuf.WellKnownTypesb\006proto3"
|
||||||
|
};
|
||||||
|
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||||
|
descriptor, 227);
|
||||||
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
|
"google/protobuf/duration.proto", &protobuf_RegisterTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptors() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||||
|
}
|
||||||
|
// Force AddDescriptors() to be called at dynamic initialization time.
|
||||||
|
struct StaticDescriptorInitializer {
|
||||||
|
StaticDescriptorInitializer() {
|
||||||
|
AddDescriptors();
|
||||||
|
}
|
||||||
|
} static_descriptor_initializer;
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fduration_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* Duration_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
Duration_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"google/protobuf/duration.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
Duration_descriptor_ = file->message_type(0);
|
|
||||||
static const int Duration_offsets_[2] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),
|
|
||||||
};
|
|
||||||
Duration_reflection_ =
|
|
||||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
|
||||||
Duration_descriptor_,
|
|
||||||
Duration::internal_default_instance(),
|
|
||||||
Duration_offsets_,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
sizeof(Duration),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
Duration_descriptor_, Duration::internal_default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() {
|
|
||||||
Duration_default_instance_.Shutdown();
|
|
||||||
delete Duration_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
Duration_default_instance_.DefaultConstruct();
|
|
||||||
Duration_default_instance_.get_mutable()->InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_);
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_,
|
|
||||||
&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl);
|
|
||||||
}
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n\036google/protobuf/duration.proto\022\017google"
|
|
||||||
".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
|
|
||||||
"\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu"
|
|
||||||
"rationProtoP\001Z*github.com/golang/protobu"
|
|
||||||
"f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot"
|
|
||||||
"obuf.WellKnownTypesb\006proto3", 227);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"google/protobuf/duration.proto", &protobuf_RegisterTypes);
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_);
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_,
|
|
||||||
&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto {
|
|
||||||
StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
static void MergeFromFail(int line) {
|
|
||||||
::google::protobuf::internal::MergeFromFail(__FILE__, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
void Duration::InitAsDefaultInstance() {
|
||||||
|
}
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
const int Duration::kSecondsFieldNumber;
|
const int Duration::kSecondsFieldNumber;
|
||||||
const int Duration::kNanosFieldNumber;
|
const int Duration::kNanosFieldNumber;
|
||||||
@@ -134,35 +129,35 @@ const int Duration::kNanosFieldNumber;
|
|||||||
|
|
||||||
Duration::Duration()
|
Duration::Duration()
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||||
if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
|
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||||
|
::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration();
|
||||||
|
}
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
// @@protoc_insertion_point(constructor:google.protobuf.Duration)
|
// @@protoc_insertion_point(constructor:google.protobuf.Duration)
|
||||||
}
|
}
|
||||||
Duration::Duration(::google::protobuf::Arena* arena)
|
Duration::Duration(::google::protobuf::Arena* arena)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(arena) {
|
_internal_metadata_(arena) {
|
||||||
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
|
::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration();
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
|
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
RegisterArenaDtor(arena);
|
RegisterArenaDtor(arena);
|
||||||
// @@protoc_insertion_point(arena_constructor:google.protobuf.Duration)
|
// @@protoc_insertion_point(arena_constructor:google.protobuf.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Duration::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Duration::Duration(const Duration& from)
|
Duration::Duration(const Duration& from)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(NULL) {
|
_internal_metadata_(NULL),
|
||||||
SharedCtor();
|
_cached_size_(0) {
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
|
::memcpy(&seconds_, &from.seconds_,
|
||||||
|
static_cast<size_t>(reinterpret_cast<char*>(&nanos_) -
|
||||||
|
reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_));
|
||||||
// @@protoc_insertion_point(copy_constructor:google.protobuf.Duration)
|
// @@protoc_insertion_point(copy_constructor:google.protobuf.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Duration::SharedCtor() {
|
void Duration::SharedCtor() {
|
||||||
::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) -
|
::memset(&seconds_, 0, static_cast<size_t>(
|
||||||
reinterpret_cast<char*>(&seconds_) + sizeof(nanos_));
|
reinterpret_cast<char*>(&nanos_) -
|
||||||
|
reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_));
|
||||||
_cached_size_ = 0;
|
_cached_size_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +167,7 @@ Duration::~Duration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Duration::SharedDtor() {
|
void Duration::SharedDtor() {
|
||||||
::google::protobuf::Arena* arena = GetArenaNoVirtual();
|
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
|
||||||
if (arena != NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Duration::ArenaDtor(void* object) {
|
void Duration::ArenaDtor(void* object) {
|
||||||
@@ -191,44 +182,29 @@ void Duration::SetCachedSize(int size) const {
|
|||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||||
}
|
}
|
||||||
const ::google::protobuf::Descriptor* Duration::descriptor() {
|
const ::google::protobuf::Descriptor* Duration::descriptor() {
|
||||||
protobuf_AssignDescriptorsOnce();
|
::protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
return Duration_descriptor_;
|
return ::protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Duration& Duration::default_instance() {
|
const Duration& Duration::default_instance() {
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
|
::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDuration();
|
||||||
return *internal_default_instance();
|
return *internal_default_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_;
|
|
||||||
|
|
||||||
Duration* Duration::New(::google::protobuf::Arena* arena) const {
|
Duration* Duration::New(::google::protobuf::Arena* arena) const {
|
||||||
return ::google::protobuf::Arena::CreateMessage<Duration>(arena);
|
return ::google::protobuf::Arena::CreateMessage<Duration>(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Duration::Clear() {
|
void Duration::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
|
||||||
#if defined(__clang__)
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
#define ZR_HELPER_(f) \
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
_Pragma("clang diagnostic push") \
|
(void) cached_has_bits;
|
||||||
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
|
|
||||||
__builtin_offsetof(Duration, f) \
|
|
||||||
_Pragma("clang diagnostic pop")
|
|
||||||
#else
|
|
||||||
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
|
|
||||||
&reinterpret_cast<Duration*>(16)->f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ZR_(first, last) do {\
|
|
||||||
::memset(&(first), 0,\
|
|
||||||
ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
ZR_(seconds_, nanos_);
|
|
||||||
|
|
||||||
#undef ZR_HELPER_
|
|
||||||
#undef ZR_
|
|
||||||
|
|
||||||
|
::memset(&seconds_, 0, static_cast<size_t>(
|
||||||
|
reinterpret_cast<char*>(&nanos_) -
|
||||||
|
reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_));
|
||||||
|
_internal_metadata_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Duration::MergePartialFromCodedStream(
|
bool Duration::MergePartialFromCodedStream(
|
||||||
@@ -237,13 +213,14 @@ bool Duration::MergePartialFromCodedStream(
|
|||||||
::google::protobuf::uint32 tag;
|
::google::protobuf::uint32 tag;
|
||||||
// @@protoc_insertion_point(parse_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(parse_start:google.protobuf.Duration)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
|
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
||||||
tag = p.first;
|
tag = p.first;
|
||||||
if (!p.second) goto handle_unusual;
|
if (!p.second) goto handle_unusual;
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||||
// optional int64 seconds = 1;
|
// int64 seconds = 1;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (tag == 8) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
|
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
|
||||||
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
|
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
|
||||||
@@ -251,14 +228,13 @@ bool Duration::MergePartialFromCodedStream(
|
|||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectTag(16)) goto parse_nanos;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
case 2: {
|
case 2: {
|
||||||
if (tag == 16) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
parse_nanos:
|
static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
|
||||||
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||||
@@ -266,18 +242,16 @@ bool Duration::MergePartialFromCodedStream(
|
|||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectAtEnd()) goto success;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if (tag == 0 ||
|
if (tag == 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
|
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||||
|
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,16 +268,23 @@ failure:
|
|||||||
void Duration::SerializeWithCachedSizes(
|
void Duration::SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
::google::protobuf::io::CodedOutputStream* output) const {
|
||||||
// @@protoc_insertion_point(serialize_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(serialize_start:google.protobuf.Duration)
|
||||||
// optional int64 seconds = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// int64 seconds = 1;
|
||||||
if (this->seconds() != 0) {
|
if (this->seconds() != 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
if (this->nanos() != 0) {
|
if (this->nanos() != 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_end:google.protobuf.Duration)
|
// @@protoc_insertion_point(serialize_end:google.protobuf.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,16 +292,23 @@ void Duration::SerializeWithCachedSizes(
|
|||||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||||
(void)deterministic; // Unused
|
(void)deterministic; // Unused
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)
|
||||||
// optional int64 seconds = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// int64 seconds = 1;
|
||||||
if (this->seconds() != 0) {
|
if (this->seconds() != 0) {
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);
|
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
if (this->nanos() != 0) {
|
if (this->nanos() != 0) {
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);
|
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration)
|
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -329,14 +317,19 @@ size_t Duration::ByteSizeLong() const {
|
|||||||
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
// optional int64 seconds = 1;
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
total_size +=
|
||||||
|
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
|
||||||
|
}
|
||||||
|
// int64 seconds = 1;
|
||||||
if (this->seconds() != 0) {
|
if (this->seconds() != 0) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::google::protobuf::internal::WireFormatLite::Int64Size(
|
::google::protobuf::internal::WireFormatLite::Int64Size(
|
||||||
this->seconds());
|
this->seconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
if (this->nanos() != 0) {
|
if (this->nanos() != 0) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
::google::protobuf::internal::WireFormatLite::Int32Size(
|
||||||
@@ -352,7 +345,7 @@ size_t Duration::ByteSizeLong() const {
|
|||||||
|
|
||||||
void Duration::MergeFrom(const ::google::protobuf::Message& from) {
|
void Duration::MergeFrom(const ::google::protobuf::Message& from) {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration)
|
||||||
if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
const Duration* source =
|
const Duration* source =
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const Duration>(
|
::google::protobuf::internal::DynamicCastToGenerated<const Duration>(
|
||||||
&from);
|
&from);
|
||||||
@@ -361,21 +354,17 @@ void Duration::MergeFrom(const ::google::protobuf::Message& from) {
|
|||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||||
} else {
|
} else {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration)
|
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration)
|
||||||
UnsafeMergeFrom(*source);
|
MergeFrom(*source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Duration::MergeFrom(const Duration& from) {
|
void Duration::MergeFrom(const Duration& from) {
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration)
|
||||||
if (GOOGLE_PREDICT_TRUE(&from != this)) {
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
} else {
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
MergeFromFail(__LINE__);
|
(void) cached_has_bits;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Duration::UnsafeMergeFrom(const Duration& from) {
|
|
||||||
GOOGLE_DCHECK(&from != this);
|
|
||||||
if (from.seconds() != 0) {
|
if (from.seconds() != 0) {
|
||||||
set_seconds(from.seconds());
|
set_seconds(from.seconds());
|
||||||
}
|
}
|
||||||
@@ -395,11 +384,10 @@ void Duration::CopyFrom(const Duration& from) {
|
|||||||
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration)
|
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
UnsafeMergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Duration::IsInitialized() const {
|
bool Duration::IsInitialized() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,10 +396,13 @@ void Duration::Swap(Duration* other) {
|
|||||||
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
} else {
|
} else {
|
||||||
Duration temp;
|
Duration* temp = New(GetArenaNoVirtual());
|
||||||
temp.UnsafeMergeFrom(*this);
|
temp->MergeFrom(*other);
|
||||||
CopyFrom(*other);
|
other->CopyFrom(*this);
|
||||||
other->CopyFrom(temp);
|
InternalSwap(temp);
|
||||||
|
if (GetArenaNoVirtual() == NULL) {
|
||||||
|
delete temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Duration::UnsafeArenaSwap(Duration* other) {
|
void Duration::UnsafeArenaSwap(Duration* other) {
|
||||||
@@ -420,58 +411,20 @@ void Duration::UnsafeArenaSwap(Duration* other) {
|
|||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
void Duration::InternalSwap(Duration* other) {
|
void Duration::InternalSwap(Duration* other) {
|
||||||
std::swap(seconds_, other->seconds_);
|
using std::swap;
|
||||||
std::swap(nanos_, other->nanos_);
|
swap(seconds_, other->seconds_);
|
||||||
|
swap(nanos_, other->nanos_);
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
swap(_cached_size_, other->_cached_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::Metadata Duration::GetMetadata() const {
|
::google::protobuf::Metadata Duration::GetMetadata() const {
|
||||||
protobuf_AssignDescriptorsOnce();
|
protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
::google::protobuf::Metadata metadata;
|
return ::protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[kIndexInFileMessages];
|
||||||
metadata.descriptor = Duration_descriptor_;
|
|
||||||
metadata.reflection = Duration_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// Duration
|
|
||||||
|
|
||||||
// optional int64 seconds = 1;
|
|
||||||
void Duration::clear_seconds() {
|
|
||||||
seconds_ = GOOGLE_LONGLONG(0);
|
|
||||||
}
|
|
||||||
::google::protobuf::int64 Duration::seconds() const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds)
|
|
||||||
return seconds_;
|
|
||||||
}
|
|
||||||
void Duration::set_seconds(::google::protobuf::int64 value) {
|
|
||||||
|
|
||||||
seconds_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
|
||||||
void Duration::clear_nanos() {
|
|
||||||
nanos_ = 0;
|
|
||||||
}
|
|
||||||
::google::protobuf::int32 Duration::nanos() const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos)
|
|
||||||
return nanos_;
|
|
||||||
}
|
|
||||||
void Duration::set_nanos(::google::protobuf::int32 value) {
|
|
||||||
|
|
||||||
nanos_ = value;
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const Duration* Duration::internal_default_instance() {
|
|
||||||
return &Duration_default_instance_.get();
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
|||||||
+84
-49
@@ -8,37 +8,55 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fduration_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[1];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsDurationImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsDuration();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsDuration();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fduration_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
|
|
||||||
class Duration;
|
class Duration;
|
||||||
|
class DurationDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -53,48 +71,69 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Duration(Duration&& from) noexcept
|
||||||
|
: Duration() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
|
inline Duration& operator=(Duration&& from) noexcept {
|
||||||
inline void* GetMaybeArenaPointer() const {
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
|
||||||
|
return GetArenaNoVirtual();
|
||||||
|
}
|
||||||
|
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
|
||||||
return MaybeArenaPtr();
|
return MaybeArenaPtr();
|
||||||
}
|
}
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Duration& default_instance();
|
static const Duration& default_instance();
|
||||||
|
|
||||||
static const Duration* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Duration* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Duration*>(
|
||||||
|
&_Duration_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
void UnsafeArenaSwap(Duration* other);
|
void UnsafeArenaSwap(Duration* other);
|
||||||
void Swap(Duration* other);
|
void Swap(Duration* other);
|
||||||
|
friend void swap(Duration& a, Duration& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Duration* New() const { return New(NULL); }
|
inline Duration* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Duration* New(::google::protobuf::Arena* arena) const;
|
Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Duration& from);
|
void CopyFrom(const Duration& from);
|
||||||
void MergeFrom(const Duration& from);
|
void MergeFrom(const Duration& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Duration* other);
|
void InternalSwap(Duration* other);
|
||||||
void UnsafeMergeFrom(const Duration& from);
|
|
||||||
protected:
|
protected:
|
||||||
explicit Duration(::google::protobuf::Arena* arena);
|
explicit Duration(::google::protobuf::Arena* arena);
|
||||||
private:
|
private:
|
||||||
@@ -109,19 +148,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional int64 seconds = 1;
|
// int64 seconds = 1;
|
||||||
void clear_seconds();
|
void clear_seconds();
|
||||||
static const int kSecondsFieldNumber = 1;
|
static const int kSecondsFieldNumber = 1;
|
||||||
::google::protobuf::int64 seconds() const;
|
::google::protobuf::int64 seconds() const;
|
||||||
void set_seconds(::google::protobuf::int64 value);
|
void set_seconds(::google::protobuf::int64 value);
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
void clear_nanos();
|
void clear_nanos();
|
||||||
static const int kNanosFieldNumber = 2;
|
static const int kNanosFieldNumber = 2;
|
||||||
::google::protobuf::int32 nanos() const;
|
::google::protobuf::int32 nanos() const;
|
||||||
@@ -131,30 +170,27 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
friend class ::google::protobuf::Arena;
|
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
::google::protobuf::int64 seconds_;
|
::google::protobuf::int64 seconds_;
|
||||||
::google::protobuf::int32 nanos_;
|
::google::protobuf::int32 nanos_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaultsDurationImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// Duration
|
// Duration
|
||||||
|
|
||||||
// optional int64 seconds = 1;
|
// int64 seconds = 1;
|
||||||
inline void Duration::clear_seconds() {
|
inline void Duration::clear_seconds() {
|
||||||
seconds_ = GOOGLE_LONGLONG(0);
|
seconds_ = GOOGLE_LONGLONG(0);
|
||||||
}
|
}
|
||||||
@@ -168,7 +204,7 @@ inline void Duration::set_seconds(::google::protobuf::int64 value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
|
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional int32 nanos = 2;
|
// int32 nanos = 2;
|
||||||
inline void Duration::clear_nanos() {
|
inline void Duration::clear_nanos() {
|
||||||
nanos_ = 0;
|
nanos_ = 0;
|
||||||
}
|
}
|
||||||
@@ -182,10 +218,9 @@ inline void Duration::set_nanos(::google::protobuf::int32 value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
|
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Duration* Duration::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &Duration_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
|
|||||||
+116
-79
@@ -77,22 +77,23 @@
|
|||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/extension_set.h>
|
||||||
|
#include <google/protobuf/map_field.h>
|
||||||
#include <google/protobuf/map_field_inl.h>
|
#include <google/protobuf/map_field_inl.h>
|
||||||
|
#include <google/protobuf/map_type_handler.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h>
|
||||||
#include <google/protobuf/map_type_handler.h>
|
|
||||||
#include <google/protobuf/extension_set.h>
|
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
#include <google/protobuf/map_field.h>
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
using internal::WireFormat;
|
using internal::DynamicMapField;
|
||||||
using internal::ExtensionSet;
|
using internal::ExtensionSet;
|
||||||
using internal::GeneratedMessageReflection;
|
using internal::GeneratedMessageReflection;
|
||||||
|
using internal::InternalMetadataWithArena;
|
||||||
using internal::MapField;
|
using internal::MapField;
|
||||||
using internal::DynamicMapField;
|
|
||||||
|
|
||||||
|
|
||||||
using internal::ArenaStringPtr;
|
using internal::ArenaStringPtr;
|
||||||
@@ -221,7 +222,7 @@ class DynamicMessage : public Message {
|
|||||||
int size;
|
int size;
|
||||||
int has_bits_offset;
|
int has_bits_offset;
|
||||||
int oneof_case_offset;
|
int oneof_case_offset;
|
||||||
int unknown_fields_offset;
|
int internal_metadata_offset;
|
||||||
int extensions_offset;
|
int extensions_offset;
|
||||||
|
|
||||||
// Not owned by the TypeInfo.
|
// Not owned by the TypeInfo.
|
||||||
@@ -231,24 +232,28 @@ class DynamicMessage : public Message {
|
|||||||
|
|
||||||
// Warning: The order in which the following pointers are defined is
|
// Warning: The order in which the following pointers are defined is
|
||||||
// important (the prototype must be deleted *before* the offsets).
|
// important (the prototype must be deleted *before* the offsets).
|
||||||
google::protobuf::scoped_array<int> offsets;
|
google::protobuf::scoped_array<uint32> offsets;
|
||||||
|
google::protobuf::scoped_array<uint32> has_bits_indices;
|
||||||
google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection;
|
google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection;
|
||||||
// Don't use a scoped_ptr to hold the prototype: the destructor for
|
// Don't use a scoped_ptr to hold the prototype: the destructor for
|
||||||
// DynamicMessage needs to know whether it is the prototype, and does so by
|
// DynamicMessage needs to know whether it is the prototype, and does so by
|
||||||
// looking back at this field. This would assume details about the
|
// looking back at this field. This would assume details about the
|
||||||
// implementation of scoped_ptr.
|
// implementation of scoped_ptr.
|
||||||
const DynamicMessage* prototype;
|
const DynamicMessage* prototype;
|
||||||
void* default_oneof_instance;
|
int weak_field_map_offset; // The offset for the weak_field_map;
|
||||||
|
|
||||||
TypeInfo() : prototype(NULL), default_oneof_instance(NULL) {}
|
TypeInfo() : prototype(NULL) {}
|
||||||
|
|
||||||
~TypeInfo() {
|
~TypeInfo() {
|
||||||
delete prototype;
|
delete prototype;
|
||||||
operator delete(default_oneof_instance);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicMessage(const TypeInfo* type_info);
|
DynamicMessage(const TypeInfo* type_info);
|
||||||
|
|
||||||
|
// This should only be used by GetPrototypeNoLock() to avoid dead lock.
|
||||||
|
DynamicMessage(const TypeInfo* type_info, bool lock_factory);
|
||||||
|
|
||||||
~DynamicMessage();
|
~DynamicMessage();
|
||||||
|
|
||||||
// Called on the prototype after construction to initialize message fields.
|
// Called on the prototype after construction to initialize message fields.
|
||||||
@@ -279,7 +284,8 @@ class DynamicMessage : public Message {
|
|||||||
private:
|
private:
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);
|
||||||
DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena);
|
DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena);
|
||||||
void SharedCtor();
|
|
||||||
|
void SharedCtor(bool lock_factory);
|
||||||
|
|
||||||
inline bool is_prototype() const {
|
inline bool is_prototype() const {
|
||||||
return type_info_->prototype == this ||
|
return type_info_->prototype == this ||
|
||||||
@@ -303,17 +309,22 @@ class DynamicMessage : public Message {
|
|||||||
DynamicMessage::DynamicMessage(const TypeInfo* type_info)
|
DynamicMessage::DynamicMessage(const TypeInfo* type_info)
|
||||||
: type_info_(type_info),
|
: type_info_(type_info),
|
||||||
cached_byte_size_(0) {
|
cached_byte_size_(0) {
|
||||||
SharedCtor();
|
SharedCtor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicMessage::DynamicMessage(const TypeInfo* type_info,
|
DynamicMessage::DynamicMessage(const TypeInfo* type_info,
|
||||||
::google::protobuf::Arena* arena)
|
::google::protobuf::Arena* arena)
|
||||||
: type_info_(type_info),
|
: type_info_(type_info),
|
||||||
cached_byte_size_(0) {
|
cached_byte_size_(0) {
|
||||||
SharedCtor();
|
SharedCtor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicMessage::SharedCtor() {
|
DynamicMessage::DynamicMessage(const TypeInfo* type_info, bool lock_factory)
|
||||||
|
: type_info_(type_info), cached_byte_size_(0) {
|
||||||
|
SharedCtor(lock_factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicMessage::SharedCtor(bool lock_factory) {
|
||||||
// We need to call constructors for various fields manually and set
|
// We need to call constructors for various fields manually and set
|
||||||
// default values where appropriate. We use placement new to call
|
// default values where appropriate. We use placement new to call
|
||||||
// constructors. If you haven't heard of placement new, I suggest Googling
|
// constructors. If you haven't heard of placement new, I suggest Googling
|
||||||
@@ -324,19 +335,18 @@ void DynamicMessage::SharedCtor() {
|
|||||||
// constructor.)
|
// constructor.)
|
||||||
|
|
||||||
const Descriptor* descriptor = type_info_->type;
|
const Descriptor* descriptor = type_info_->type;
|
||||||
|
|
||||||
// Initialize oneof cases.
|
// Initialize oneof cases.
|
||||||
for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) {
|
for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) {
|
||||||
new(OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i))
|
new (OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i))
|
||||||
uint32(0);
|
uint32(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet;
|
new (OffsetToPointer(type_info_->internal_metadata_offset))
|
||||||
|
InternalMetadataWithArena;
|
||||||
|
|
||||||
if (type_info_->extensions_offset != -1) {
|
if (type_info_->extensions_offset != -1) {
|
||||||
new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;
|
new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < descriptor->field_count(); i++) {
|
for (int i = 0; i < descriptor->field_count(); i++) {
|
||||||
const FieldDescriptor* field = descriptor->field(i);
|
const FieldDescriptor* field = descriptor->field(i);
|
||||||
void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
|
void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
|
||||||
@@ -379,10 +389,10 @@ void DynamicMessage::SharedCtor() {
|
|||||||
if (is_prototype()) {
|
if (is_prototype()) {
|
||||||
default_value = &field->default_value_string();
|
default_value = &field->default_value_string();
|
||||||
} else {
|
} else {
|
||||||
default_value =
|
default_value = &(reinterpret_cast<const ArenaStringPtr*>(
|
||||||
&(reinterpret_cast<const ArenaStringPtr*>(
|
type_info_->prototype->OffsetToPointer(
|
||||||
type_info_->prototype->OffsetToPointer(
|
type_info_->offsets[i]))
|
||||||
type_info_->offsets[i]))->Get(NULL));
|
->Get());
|
||||||
}
|
}
|
||||||
ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr();
|
ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr();
|
||||||
asp->UnsafeSetDefault(default_value);
|
asp->UnsafeSetDefault(default_value);
|
||||||
@@ -398,8 +408,17 @@ void DynamicMessage::SharedCtor() {
|
|||||||
new(field_ptr) Message*(NULL);
|
new(field_ptr) Message*(NULL);
|
||||||
} else {
|
} else {
|
||||||
if (IsMapFieldInApi(field)) {
|
if (IsMapFieldInApi(field)) {
|
||||||
new (field_ptr) DynamicMapField(
|
// We need to lock in most cases to avoid data racing. Only not lock
|
||||||
type_info_->factory->GetPrototypeNoLock(field->message_type()));
|
// when the constructor is called inside GetPrototype(), in which
|
||||||
|
// case we have already locked the factory.
|
||||||
|
if (lock_factory) {
|
||||||
|
new (field_ptr) DynamicMapField(
|
||||||
|
type_info_->factory->GetPrototype(field->message_type()));
|
||||||
|
} else {
|
||||||
|
new (field_ptr)
|
||||||
|
DynamicMapField(type_info_->factory->GetPrototypeNoLock(
|
||||||
|
field->message_type()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new (field_ptr) RepeatedPtrField<Message>();
|
new (field_ptr) RepeatedPtrField<Message>();
|
||||||
}
|
}
|
||||||
@@ -413,8 +432,9 @@ void DynamicMessage::SharedCtor() {
|
|||||||
DynamicMessage::~DynamicMessage() {
|
DynamicMessage::~DynamicMessage() {
|
||||||
const Descriptor* descriptor = type_info_->type;
|
const Descriptor* descriptor = type_info_->type;
|
||||||
|
|
||||||
reinterpret_cast<UnknownFieldSet*>(
|
reinterpret_cast<InternalMetadataWithArena*>(
|
||||||
OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet();
|
OffsetToPointer(type_info_->internal_metadata_offset))
|
||||||
|
->~InternalMetadataWithArena();
|
||||||
|
|
||||||
if (type_info_->extensions_offset != -1) {
|
if (type_info_->extensions_offset != -1) {
|
||||||
reinterpret_cast<ExtensionSet*>(
|
reinterpret_cast<ExtensionSet*>(
|
||||||
@@ -445,10 +465,10 @@ DynamicMessage::~DynamicMessage() {
|
|||||||
case FieldOptions::STRING: {
|
case FieldOptions::STRING: {
|
||||||
const ::std::string* default_value =
|
const ::std::string* default_value =
|
||||||
&(reinterpret_cast<const ArenaStringPtr*>(
|
&(reinterpret_cast<const ArenaStringPtr*>(
|
||||||
reinterpret_cast<uint8*>(
|
reinterpret_cast<const uint8*>(
|
||||||
type_info_->default_oneof_instance)
|
type_info_->prototype) +
|
||||||
+ type_info_->offsets[i])
|
type_info_->offsets[i])
|
||||||
->Get(NULL));
|
->Get());
|
||||||
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
|
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
|
||||||
default_value, NULL);
|
default_value, NULL);
|
||||||
break;
|
break;
|
||||||
@@ -506,8 +526,9 @@ DynamicMessage::~DynamicMessage() {
|
|||||||
case FieldOptions::STRING: {
|
case FieldOptions::STRING: {
|
||||||
const ::std::string* default_value =
|
const ::std::string* default_value =
|
||||||
&(reinterpret_cast<const ArenaStringPtr*>(
|
&(reinterpret_cast<const ArenaStringPtr*>(
|
||||||
type_info_->prototype->OffsetToPointer(
|
type_info_->prototype->OffsetToPointer(
|
||||||
type_info_->offsets[i]))->Get(NULL));
|
type_info_->offsets[i]))
|
||||||
|
->Get());
|
||||||
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
|
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
|
||||||
default_value, NULL);
|
default_value, NULL);
|
||||||
break;
|
break;
|
||||||
@@ -535,11 +556,6 @@ void DynamicMessage::CrossLinkPrototypes() {
|
|||||||
for (int i = 0; i < descriptor->field_count(); i++) {
|
for (int i = 0; i < descriptor->field_count(); i++) {
|
||||||
const FieldDescriptor* field = descriptor->field(i);
|
const FieldDescriptor* field = descriptor->field(i);
|
||||||
void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
|
void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
|
||||||
if (field->containing_oneof()) {
|
|
||||||
field_ptr = reinterpret_cast<uint8*>(
|
|
||||||
type_info_->default_oneof_instance) + type_info_->offsets[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
|
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
|
||||||
!field->is_repeated()) {
|
!field->is_repeated()) {
|
||||||
// For fields with message types, we need to cross-link with the
|
// For fields with message types, we need to cross-link with the
|
||||||
@@ -610,7 +626,7 @@ DynamicMessageFactory::~DynamicMessageFactory() {
|
|||||||
iter != prototypes_->map_.end(); ++iter) {
|
iter != prototypes_->map_.end(); ++iter) {
|
||||||
DeleteDefaultOneofInstance(iter->second->type,
|
DeleteDefaultOneofInstance(iter->second->type,
|
||||||
iter->second->offsets.get(),
|
iter->second->offsets.get(),
|
||||||
iter->second->default_oneof_instance);
|
iter->second->prototype);
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,7 +665,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
// or not that field is set.
|
// or not that field is set.
|
||||||
|
|
||||||
// Compute size and offsets.
|
// Compute size and offsets.
|
||||||
int* offsets = new int[type->field_count() + type->oneof_decl_count()];
|
uint32* offsets =
|
||||||
|
new uint32[type->field_count() + type->oneof_decl_count()];
|
||||||
type_info->offsets.reset(offsets);
|
type_info->offsets.reset(offsets);
|
||||||
|
|
||||||
// Decide all field offsets by packing in order.
|
// Decide all field offsets by packing in order.
|
||||||
@@ -667,6 +684,12 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
DivideRoundingUp(type->field_count(), bitsizeof(uint32));
|
DivideRoundingUp(type->field_count(), bitsizeof(uint32));
|
||||||
size += has_bits_array_size * sizeof(uint32);
|
size += has_bits_array_size * sizeof(uint32);
|
||||||
size = AlignOffset(size);
|
size = AlignOffset(size);
|
||||||
|
|
||||||
|
uint32* has_bits_indices = new uint32[type->field_count()];
|
||||||
|
for (int i = 0; i < type->field_count(); i++) {
|
||||||
|
has_bits_indices[i] = i;
|
||||||
|
}
|
||||||
|
type_info->has_bits_indices.reset(has_bits_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The oneof_case, if any. It is an array of uint32s.
|
// The oneof_case, if any. It is an array of uint32s.
|
||||||
@@ -687,6 +710,9 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All the fields.
|
// All the fields.
|
||||||
|
//
|
||||||
|
// TODO(b/31226269): Optimize the order of fields to minimize padding.
|
||||||
|
int num_weak_fields = 0;
|
||||||
for (int i = 0; i < type->field_count(); i++) {
|
for (int i = 0; i < type->field_count(); i++) {
|
||||||
// Make sure field is aligned to avoid bus errors.
|
// Make sure field is aligned to avoid bus errors.
|
||||||
// Oneof fields do not use any space.
|
// Oneof fields do not use any space.
|
||||||
@@ -705,19 +731,38 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
size += kMaxOneofUnionSize;
|
size += kMaxOneofUnionSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the UnknownFieldSet to the end.
|
// Add the InternalMetadataWithArena to the end.
|
||||||
size = AlignOffset(size);
|
size = AlignOffset(size);
|
||||||
type_info->unknown_fields_offset = size;
|
type_info->internal_metadata_offset = size;
|
||||||
size += sizeof(UnknownFieldSet);
|
size += sizeof(InternalMetadataWithArena);
|
||||||
|
|
||||||
|
type_info->weak_field_map_offset = -1;
|
||||||
|
|
||||||
// Align the final size to make sure no clever allocators think that
|
// Align the final size to make sure no clever allocators think that
|
||||||
// alignment is not necessary.
|
// alignment is not necessary.
|
||||||
size = AlignOffset(size);
|
|
||||||
type_info->size = size;
|
type_info->size = size;
|
||||||
|
|
||||||
// Allocate the prototype.
|
|
||||||
|
// Construct the reflection object.
|
||||||
|
|
||||||
|
if (type->oneof_decl_count() > 0) {
|
||||||
|
// Compute the size of default oneof instance and offsets of default
|
||||||
|
// oneof fields.
|
||||||
|
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
||||||
|
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
||||||
|
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
||||||
|
int field_size = OneofFieldSpaceUsed(field);
|
||||||
|
size = AlignTo(size, std::min(kSafeAlignment, field_size));
|
||||||
|
offsets[field->index()] = size;
|
||||||
|
size += field_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = AlignOffset(size);
|
||||||
|
// Allocate the prototype + oneof fields.
|
||||||
void* base = operator new(size);
|
void* base = operator new(size);
|
||||||
memset(base, 0, size);
|
memset(base, 0, size);
|
||||||
|
|
||||||
// The prototype in type_info has to be set before creating the prototype
|
// The prototype in type_info has to be set before creating the prototype
|
||||||
// instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When
|
// instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When
|
||||||
// creating prototype for Foo, prototype of the map entry will also be
|
// creating prototype for Foo, prototype of the map entry will also be
|
||||||
@@ -725,40 +770,32 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
// map). To break the cyclic dependency, we have to assgin the address of
|
// map). To break the cyclic dependency, we have to assgin the address of
|
||||||
// prototype into type_info first.
|
// prototype into type_info first.
|
||||||
type_info->prototype = static_cast<DynamicMessage*>(base);
|
type_info->prototype = static_cast<DynamicMessage*>(base);
|
||||||
DynamicMessage* prototype = new(base) DynamicMessage(type_info);
|
|
||||||
|
|
||||||
// Construct the reflection object.
|
// We have already locked the factory so we should not lock in the constructor
|
||||||
if (type->oneof_decl_count() > 0) {
|
// of dynamic message to avoid dead lock.
|
||||||
// Compute the size of default oneof instance and offsets of default
|
DynamicMessage* prototype = new (base) DynamicMessage(type_info, false);
|
||||||
// oneof fields.
|
|
||||||
int oneof_size = 0;
|
if (type->oneof_decl_count() > 0 || num_weak_fields > 0) {
|
||||||
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
|
||||||
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
|
||||||
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
|
||||||
int field_size = OneofFieldSpaceUsed(field);
|
|
||||||
oneof_size = AlignTo(oneof_size, std::min(kSafeAlignment, field_size));
|
|
||||||
offsets[field->index()] = oneof_size;
|
|
||||||
oneof_size += field_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Construct default oneof instance.
|
// Construct default oneof instance.
|
||||||
type_info->default_oneof_instance = ::operator new(oneof_size);
|
|
||||||
ConstructDefaultOneofInstance(type_info->type,
|
ConstructDefaultOneofInstance(type_info->type,
|
||||||
type_info->offsets.get(),
|
type_info->offsets.get(),
|
||||||
type_info->default_oneof_instance);
|
prototype);
|
||||||
type_info->reflection.reset(new GeneratedMessageReflection(
|
|
||||||
type_info->type, type_info->prototype, type_info->offsets.get(),
|
|
||||||
type_info->has_bits_offset, type_info->unknown_fields_offset,
|
|
||||||
type_info->extensions_offset, type_info->default_oneof_instance,
|
|
||||||
type_info->oneof_case_offset, type_info->pool, this, type_info->size,
|
|
||||||
-1 /* arena_offset */));
|
|
||||||
} else {
|
|
||||||
type_info->reflection.reset(new GeneratedMessageReflection(
|
|
||||||
type_info->type, type_info->prototype, type_info->offsets.get(),
|
|
||||||
type_info->has_bits_offset, type_info->unknown_fields_offset,
|
|
||||||
type_info->extensions_offset, type_info->pool, this, type_info->size,
|
|
||||||
-1 /* arena_offset */));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal::ReflectionSchema schema = {
|
||||||
|
type_info->prototype,
|
||||||
|
type_info->offsets.get(),
|
||||||
|
type_info->has_bits_indices.get(),
|
||||||
|
type_info->has_bits_offset,
|
||||||
|
type_info->internal_metadata_offset,
|
||||||
|
type_info->extensions_offset,
|
||||||
|
type_info->oneof_case_offset,
|
||||||
|
type_info->size,
|
||||||
|
type_info->weak_field_map_offset};
|
||||||
|
|
||||||
|
type_info->reflection.reset(new GeneratedMessageReflection(
|
||||||
|
type_info->type, schema, type_info->pool, this));
|
||||||
|
|
||||||
// Cross link prototypes.
|
// Cross link prototypes.
|
||||||
prototype->CrossLinkPrototypes();
|
prototype->CrossLinkPrototypes();
|
||||||
|
|
||||||
@@ -767,13 +804,13 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
|
|||||||
|
|
||||||
void DynamicMessageFactory::ConstructDefaultOneofInstance(
|
void DynamicMessageFactory::ConstructDefaultOneofInstance(
|
||||||
const Descriptor* type,
|
const Descriptor* type,
|
||||||
const int offsets[],
|
const uint32 offsets[],
|
||||||
void* default_oneof_instance) {
|
void* default_oneof_or_weak_instance) {
|
||||||
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
||||||
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
||||||
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
||||||
void* field_ptr = reinterpret_cast<uint8*>(
|
void* field_ptr = reinterpret_cast<uint8*>(
|
||||||
default_oneof_instance) + offsets[field->index()];
|
default_oneof_or_weak_instance) + offsets[field->index()];
|
||||||
switch (field->cpp_type()) {
|
switch (field->cpp_type()) {
|
||||||
#define HANDLE_TYPE(CPPTYPE, TYPE) \
|
#define HANDLE_TYPE(CPPTYPE, TYPE) \
|
||||||
case FieldDescriptor::CPPTYPE_##CPPTYPE: \
|
case FieldDescriptor::CPPTYPE_##CPPTYPE: \
|
||||||
@@ -813,8 +850,8 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance(
|
|||||||
|
|
||||||
void DynamicMessageFactory::DeleteDefaultOneofInstance(
|
void DynamicMessageFactory::DeleteDefaultOneofInstance(
|
||||||
const Descriptor* type,
|
const Descriptor* type,
|
||||||
const int offsets[],
|
const uint32 offsets[],
|
||||||
void* default_oneof_instance) {
|
const void* default_oneof_instance) {
|
||||||
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
for (int i = 0; i < type->oneof_decl_count(); i++) {
|
||||||
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
|
||||||
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
|
||||||
|
|||||||
+87
-3
@@ -38,12 +38,15 @@
|
|||||||
#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
||||||
#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef _SHARED_PTR_H
|
#ifndef _SHARED_PTR_H
|
||||||
#include <google/protobuf/stubs/shared_ptr.h>
|
#include <google/protobuf/stubs/shared_ptr.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
|
#include <google/protobuf/repeated_field.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/mutex.h>
|
#include <google/protobuf/stubs/mutex.h>
|
||||||
|
|
||||||
@@ -136,16 +139,97 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
|
|||||||
// Construct default oneof instance for reflection usage if oneof
|
// Construct default oneof instance for reflection usage if oneof
|
||||||
// is defined.
|
// is defined.
|
||||||
static void ConstructDefaultOneofInstance(const Descriptor* type,
|
static void ConstructDefaultOneofInstance(const Descriptor* type,
|
||||||
const int offsets[],
|
const uint32 offsets[],
|
||||||
void* default_oneof_instance);
|
void* default_oneof_instance);
|
||||||
// Delete default oneof instance. Called by ~DynamicMessageFactory.
|
// Delete default oneof instance. Called by ~DynamicMessageFactory.
|
||||||
static void DeleteDefaultOneofInstance(const Descriptor* type,
|
static void DeleteDefaultOneofInstance(const Descriptor* type,
|
||||||
const int offsets[],
|
const uint32 offsets[],
|
||||||
void* default_oneof_instance);
|
const void* default_oneof_instance);
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper for computing a sorted list of map entries via reflection.
|
||||||
|
class LIBPROTOBUF_EXPORT DynamicMapSorter {
|
||||||
|
public:
|
||||||
|
static std::vector<const Message*> Sort(const Message& message,
|
||||||
|
int map_size,
|
||||||
|
const Reflection* reflection,
|
||||||
|
const FieldDescriptor* field) {
|
||||||
|
std::vector<const Message*> result(static_cast<size_t>(map_size));
|
||||||
|
const RepeatedPtrField<Message>& map_field =
|
||||||
|
reflection->GetRepeatedPtrField<Message>(message, field);
|
||||||
|
size_t i = 0;
|
||||||
|
for (RepeatedPtrField<Message>::const_pointer_iterator it =
|
||||||
|
map_field.pointer_begin(); it != map_field.pointer_end(); ) {
|
||||||
|
result[i++] = *it++;
|
||||||
|
}
|
||||||
|
GOOGLE_DCHECK_EQ(result.size(), i);
|
||||||
|
MapEntryMessageComparator comparator(field->message_type());
|
||||||
|
std::stable_sort(result.begin(), result.end(), comparator);
|
||||||
|
// Complain if the keys aren't in ascending order.
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (size_t j = 1; j < static_cast<size_t>(map_size); j++) {
|
||||||
|
if (!comparator(result[j - 1], result[j])) {
|
||||||
|
GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1]) ?
|
||||||
|
"internal error in map key sorting" :
|
||||||
|
"map keys are not unique");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
class LIBPROTOBUF_EXPORT MapEntryMessageComparator {
|
||||||
|
public:
|
||||||
|
explicit MapEntryMessageComparator(const Descriptor* descriptor)
|
||||||
|
: field_(descriptor->field(0)) {}
|
||||||
|
|
||||||
|
bool operator()(const Message* a, const Message* b) {
|
||||||
|
const Reflection* reflection = a->GetReflection();
|
||||||
|
switch (field_->cpp_type()) {
|
||||||
|
case FieldDescriptor::CPPTYPE_BOOL: {
|
||||||
|
bool first = reflection->GetBool(*a, field_);
|
||||||
|
bool second = reflection->GetBool(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
case FieldDescriptor::CPPTYPE_INT32: {
|
||||||
|
int32 first = reflection->GetInt32(*a, field_);
|
||||||
|
int32 second = reflection->GetInt32(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
case FieldDescriptor::CPPTYPE_INT64: {
|
||||||
|
int64 first = reflection->GetInt64(*a, field_);
|
||||||
|
int64 second = reflection->GetInt64(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT32: {
|
||||||
|
uint32 first = reflection->GetUInt32(*a, field_);
|
||||||
|
uint32 second = reflection->GetUInt32(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT64: {
|
||||||
|
uint64 first = reflection->GetUInt64(*a, field_);
|
||||||
|
uint64 second = reflection->GetUInt64(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
case FieldDescriptor::CPPTYPE_STRING: {
|
||||||
|
string first = reflection->GetString(*a, field_);
|
||||||
|
string second = reflection->GetString(*b, field_);
|
||||||
|
return first < second;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const FieldDescriptor* field_;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|||||||
+155
-159
@@ -1,7 +1,6 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: google/protobuf/empty.proto
|
// source: google/protobuf/empty.proto
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include <google/protobuf/empty.pb.h>
|
#include <google/protobuf/empty.pb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -15,143 +14,135 @@
|
|||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
|
// This is a temporary google only hack
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
#include "third_party/protobuf/version.h"
|
||||||
|
#endif
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
class EmptyDefaultTypeInternal {
|
||||||
|
public:
|
||||||
|
::google::protobuf::internal::ExplicitlyConstructed<Empty>
|
||||||
|
_instance;
|
||||||
|
} _Empty_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace protobuf_google_2fprotobuf_2fempty_2eproto {
|
||||||
|
void InitDefaultsEmptyImpl() {
|
||||||
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
|
||||||
|
#else
|
||||||
|
::google::protobuf::internal::InitProtobufDefaults();
|
||||||
|
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
{
|
||||||
|
void* ptr = &::google::protobuf::_Empty_default_instance_;
|
||||||
|
new (ptr) ::google::protobuf::Empty();
|
||||||
|
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
||||||
|
}
|
||||||
|
::google::protobuf::Empty::InitAsDefaultInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDefaultsEmpty() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsEmptyImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
::google::protobuf::Metadata file_level_metadata[1];
|
||||||
|
|
||||||
|
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
~0u, // no _has_bits_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Empty, _internal_metadata_),
|
||||||
|
~0u, // no _extensions_
|
||||||
|
~0u, // no _oneof_case_
|
||||||
|
~0u, // no _weak_field_map_
|
||||||
|
};
|
||||||
|
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
{ 0, -1, sizeof(::google::protobuf::Empty)},
|
||||||
|
};
|
||||||
|
|
||||||
|
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||||
|
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Empty_default_instance_),
|
||||||
|
};
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptors() {
|
||||||
|
AddDescriptors();
|
||||||
|
::google::protobuf::MessageFactory* factory = NULL;
|
||||||
|
AssignDescriptors(
|
||||||
|
"google/protobuf/empty.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||||
|
file_level_metadata, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptorsOnce() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) {
|
||||||
|
protobuf_AssignDescriptorsOnce();
|
||||||
|
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptorsImpl() {
|
||||||
|
InitDefaults();
|
||||||
|
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
"\n\033google/protobuf/empty.proto\022\017google.pr"
|
||||||
|
"otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n"
|
||||||
|
"EmptyProtoP\001Z\'github.com/golang/protobuf"
|
||||||
|
"/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
|
||||||
|
".WellKnownTypesb\006proto3"
|
||||||
|
};
|
||||||
|
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||||
|
descriptor, 183);
|
||||||
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
|
"google/protobuf/empty.proto", &protobuf_RegisterTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptors() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||||
|
}
|
||||||
|
// Force AddDescriptors() to be called at dynamic initialization time.
|
||||||
|
struct StaticDescriptorInitializer {
|
||||||
|
StaticDescriptorInitializer() {
|
||||||
|
AddDescriptors();
|
||||||
|
}
|
||||||
|
} static_descriptor_initializer;
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fempty_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* Empty_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
Empty_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"google/protobuf/empty.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
Empty_descriptor_ = file->message_type(0);
|
|
||||||
static const int Empty_offsets_[1] = {
|
|
||||||
};
|
|
||||||
Empty_reflection_ =
|
|
||||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
|
||||||
Empty_descriptor_,
|
|
||||||
Empty::internal_default_instance(),
|
|
||||||
Empty_offsets_,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
sizeof(Empty),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
Empty_descriptor_, Empty::internal_default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() {
|
|
||||||
Empty_default_instance_.Shutdown();
|
|
||||||
delete Empty_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
Empty_default_instance_.DefaultConstruct();
|
|
||||||
Empty_default_instance_.get_mutable()->InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_);
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_,
|
|
||||||
&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl);
|
|
||||||
}
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n\033google/protobuf/empty.proto\022\017google.pr"
|
|
||||||
"otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n"
|
|
||||||
"EmptyProtoP\001Z\'github.com/golang/protobuf"
|
|
||||||
"/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
|
|
||||||
".WellKnownTypesb\006proto3", 183);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"google/protobuf/empty.proto", &protobuf_RegisterTypes);
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_);
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_,
|
|
||||||
&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto {
|
|
||||||
StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
static void MergeFromFail(int line) {
|
|
||||||
::google::protobuf::internal::MergeFromFail(__FILE__, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
void Empty::InitAsDefaultInstance() {
|
||||||
|
}
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
|
|
||||||
Empty::Empty()
|
Empty::Empty()
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||||
if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
|
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||||
|
::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty();
|
||||||
|
}
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
// @@protoc_insertion_point(constructor:google.protobuf.Empty)
|
// @@protoc_insertion_point(constructor:google.protobuf.Empty)
|
||||||
}
|
}
|
||||||
Empty::Empty(::google::protobuf::Arena* arena)
|
Empty::Empty(::google::protobuf::Arena* arena)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(arena) {
|
_internal_metadata_(arena) {
|
||||||
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
|
::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty();
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
|
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
RegisterArenaDtor(arena);
|
RegisterArenaDtor(arena);
|
||||||
// @@protoc_insertion_point(arena_constructor:google.protobuf.Empty)
|
// @@protoc_insertion_point(arena_constructor:google.protobuf.Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Empty::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Empty::Empty(const Empty& from)
|
Empty::Empty(const Empty& from)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(NULL) {
|
_internal_metadata_(NULL),
|
||||||
SharedCtor();
|
_cached_size_(0) {
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
// @@protoc_insertion_point(copy_constructor:google.protobuf.Empty)
|
// @@protoc_insertion_point(copy_constructor:google.protobuf.Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,11 +156,7 @@ Empty::~Empty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Empty::SharedDtor() {
|
void Empty::SharedDtor() {
|
||||||
::google::protobuf::Arena* arena = GetArenaNoVirtual();
|
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
|
||||||
if (arena != NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Empty::ArenaDtor(void* object) {
|
void Empty::ArenaDtor(void* object) {
|
||||||
@@ -184,23 +171,26 @@ void Empty::SetCachedSize(int size) const {
|
|||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||||
}
|
}
|
||||||
const ::google::protobuf::Descriptor* Empty::descriptor() {
|
const ::google::protobuf::Descriptor* Empty::descriptor() {
|
||||||
protobuf_AssignDescriptorsOnce();
|
::protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
return Empty_descriptor_;
|
return ::protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Empty& Empty::default_instance() {
|
const Empty& Empty::default_instance() {
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
|
::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmpty();
|
||||||
return *internal_default_instance();
|
return *internal_default_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_;
|
|
||||||
|
|
||||||
Empty* Empty::New(::google::protobuf::Arena* arena) const {
|
Empty* Empty::New(::google::protobuf::Arena* arena) const {
|
||||||
return ::google::protobuf::Arena::CreateMessage<Empty>(arena);
|
return ::google::protobuf::Arena::CreateMessage<Empty>(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Empty::Clear() {
|
void Empty::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(message_clear_start:google.protobuf.Empty)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
_internal_metadata_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Empty::MergePartialFromCodedStream(
|
bool Empty::MergePartialFromCodedStream(
|
||||||
@@ -209,16 +199,15 @@ bool Empty::MergePartialFromCodedStream(
|
|||||||
::google::protobuf::uint32 tag;
|
::google::protobuf::uint32 tag;
|
||||||
// @@protoc_insertion_point(parse_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(parse_start:google.protobuf.Empty)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
|
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
||||||
tag = p.first;
|
tag = p.first;
|
||||||
if (!p.second) goto handle_unusual;
|
if (!p.second) goto handle_unusual;
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if (tag == 0 ||
|
if (tag == 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
|
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||||
|
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
||||||
}
|
}
|
||||||
success:
|
success:
|
||||||
// @@protoc_insertion_point(parse_success:google.protobuf.Empty)
|
// @@protoc_insertion_point(parse_success:google.protobuf.Empty)
|
||||||
@@ -232,6 +221,13 @@ failure:
|
|||||||
void Empty::SerializeWithCachedSizes(
|
void Empty::SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
::google::protobuf::io::CodedOutputStream* output) const {
|
||||||
// @@protoc_insertion_point(serialize_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(serialize_start:google.protobuf.Empty)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_end:google.protobuf.Empty)
|
// @@protoc_insertion_point(serialize_end:google.protobuf.Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +235,13 @@ void Empty::SerializeWithCachedSizes(
|
|||||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||||
(void)deterministic; // Unused
|
(void)deterministic; // Unused
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty)
|
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -247,6 +250,11 @@ size_t Empty::ByteSizeLong() const {
|
|||||||
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
total_size +=
|
||||||
|
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
|
||||||
|
}
|
||||||
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
|
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||||
_cached_size_ = cached_size;
|
_cached_size_ = cached_size;
|
||||||
@@ -256,7 +264,7 @@ size_t Empty::ByteSizeLong() const {
|
|||||||
|
|
||||||
void Empty::MergeFrom(const ::google::protobuf::Message& from) {
|
void Empty::MergeFrom(const ::google::protobuf::Message& from) {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty)
|
||||||
if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
const Empty* source =
|
const Empty* source =
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const Empty>(
|
::google::protobuf::internal::DynamicCastToGenerated<const Empty>(
|
||||||
&from);
|
&from);
|
||||||
@@ -265,21 +273,17 @@ void Empty::MergeFrom(const ::google::protobuf::Message& from) {
|
|||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||||
} else {
|
} else {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty)
|
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty)
|
||||||
UnsafeMergeFrom(*source);
|
MergeFrom(*source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Empty::MergeFrom(const Empty& from) {
|
void Empty::MergeFrom(const Empty& from) {
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty)
|
||||||
if (GOOGLE_PREDICT_TRUE(&from != this)) {
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
} else {
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
MergeFromFail(__LINE__);
|
(void) cached_has_bits;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Empty::UnsafeMergeFrom(const Empty& from) {
|
|
||||||
GOOGLE_DCHECK(&from != this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Empty::CopyFrom(const ::google::protobuf::Message& from) {
|
void Empty::CopyFrom(const ::google::protobuf::Message& from) {
|
||||||
@@ -293,11 +297,10 @@ void Empty::CopyFrom(const Empty& from) {
|
|||||||
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty)
|
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
UnsafeMergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Empty::IsInitialized() const {
|
bool Empty::IsInitialized() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,10 +309,13 @@ void Empty::Swap(Empty* other) {
|
|||||||
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
} else {
|
} else {
|
||||||
Empty temp;
|
Empty* temp = New(GetArenaNoVirtual());
|
||||||
temp.UnsafeMergeFrom(*this);
|
temp->MergeFrom(*other);
|
||||||
CopyFrom(*other);
|
other->CopyFrom(*this);
|
||||||
other->CopyFrom(temp);
|
InternalSwap(temp);
|
||||||
|
if (GetArenaNoVirtual() == NULL) {
|
||||||
|
delete temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Empty::UnsafeArenaSwap(Empty* other) {
|
void Empty::UnsafeArenaSwap(Empty* other) {
|
||||||
@@ -318,28 +324,18 @@ void Empty::UnsafeArenaSwap(Empty* other) {
|
|||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
void Empty::InternalSwap(Empty* other) {
|
void Empty::InternalSwap(Empty* other) {
|
||||||
|
using std::swap;
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
swap(_cached_size_, other->_cached_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::Metadata Empty::GetMetadata() const {
|
::google::protobuf::Metadata Empty::GetMetadata() const {
|
||||||
protobuf_AssignDescriptorsOnce();
|
protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
::google::protobuf::Metadata metadata;
|
return ::protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[kIndexInFileMessages];
|
||||||
metadata.descriptor = Empty_descriptor_;
|
|
||||||
metadata.reflection = Empty_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// Empty
|
|
||||||
|
|
||||||
inline const Empty* Empty::internal_default_instance() {
|
|
||||||
return &Empty_default_instance_.get();
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
|||||||
+80
-45
@@ -8,37 +8,55 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fempty_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[1];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsEmptyImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsEmpty();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsEmpty();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fempty_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
|
|
||||||
class Empty;
|
class Empty;
|
||||||
|
class EmptyDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -53,48 +71,69 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Empty(Empty&& from) noexcept
|
||||||
|
: Empty() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
|
inline Empty& operator=(Empty&& from) noexcept {
|
||||||
inline void* GetMaybeArenaPointer() const {
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
|
||||||
|
return GetArenaNoVirtual();
|
||||||
|
}
|
||||||
|
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
|
||||||
return MaybeArenaPtr();
|
return MaybeArenaPtr();
|
||||||
}
|
}
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Empty& default_instance();
|
static const Empty& default_instance();
|
||||||
|
|
||||||
static const Empty* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Empty* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Empty*>(
|
||||||
|
&_Empty_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
void UnsafeArenaSwap(Empty* other);
|
void UnsafeArenaSwap(Empty* other);
|
||||||
void Swap(Empty* other);
|
void Swap(Empty* other);
|
||||||
|
friend void swap(Empty& a, Empty& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Empty* New() const { return New(NULL); }
|
inline Empty* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Empty* New(::google::protobuf::Arena* arena) const;
|
Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Empty& from);
|
void CopyFrom(const Empty& from);
|
||||||
void MergeFrom(const Empty& from);
|
void MergeFrom(const Empty& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Empty* other);
|
void InternalSwap(Empty* other);
|
||||||
void UnsafeMergeFrom(const Empty& from);
|
|
||||||
protected:
|
protected:
|
||||||
explicit Empty(::google::protobuf::Arena* arena);
|
explicit Empty(::google::protobuf::Arena* arena);
|
||||||
private:
|
private:
|
||||||
@@ -109,7 +148,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
@@ -119,31 +158,27 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
friend class ::google::protobuf::Arena;
|
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaultsEmptyImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// Empty
|
// Empty
|
||||||
|
|
||||||
inline const Empty* Empty::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &Empty_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -76,7 +76,7 @@ inline bool is_packable(WireFormatLite::WireType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Registry stuff.
|
// Registry stuff.
|
||||||
typedef hash_map<pair<const MessageLite*, int>,
|
typedef hash_map<std::pair<const MessageLite*, int>,
|
||||||
ExtensionInfo> ExtensionRegistry;
|
ExtensionInfo> ExtensionRegistry;
|
||||||
ExtensionRegistry* registry_ = NULL;
|
ExtensionRegistry* registry_ = NULL;
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_);
|
GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_);
|
||||||
@@ -221,7 +221,7 @@ int ExtensionSet::NumExtensions() const {
|
|||||||
|
|
||||||
int ExtensionSet::ExtensionSize(int number) const {
|
int ExtensionSet::ExtensionSize(int number) const {
|
||||||
ExtensionMap::const_iterator iter = extensions_.find(number);
|
ExtensionMap::const_iterator iter = extensions_.find(number);
|
||||||
if (iter == extensions_.end()) return false;
|
if (iter == extensions_.end()) return 0;
|
||||||
return iter->second.GetSize();
|
return iter->second.GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1371,7 +1371,7 @@ size_t ExtensionSet::ByteSize() const {
|
|||||||
bool ExtensionSet::MaybeNewExtension(int number,
|
bool ExtensionSet::MaybeNewExtension(int number,
|
||||||
const FieldDescriptor* descriptor,
|
const FieldDescriptor* descriptor,
|
||||||
Extension** result) {
|
Extension** result) {
|
||||||
pair<ExtensionMap::iterator, bool> insert_result =
|
std::pair<ExtensionMap::iterator, bool> insert_result =
|
||||||
extensions_.insert(std::make_pair(number, Extension()));
|
extensions_.insert(std::make_pair(number, Extension()));
|
||||||
*result = &insert_result.first->second;
|
*result = &insert_result.first->second;
|
||||||
(*result)->descriptor = descriptor;
|
(*result)->descriptor = descriptor;
|
||||||
|
|||||||
+67
-6
@@ -416,7 +416,8 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
|
|||||||
uint8* target) const;
|
uint8* target) const;
|
||||||
|
|
||||||
// For backward-compatibility, versions of two of the above methods that
|
// For backward-compatibility, versions of two of the above methods that
|
||||||
// are never forced to serialize deterministically.
|
// serialize deterministically iff SetDefaultSerializationDeterministic()
|
||||||
|
// has been called.
|
||||||
uint8* SerializeWithCachedSizesToArray(int start_field_number,
|
uint8* SerializeWithCachedSizesToArray(int start_field_number,
|
||||||
int end_field_number,
|
int end_field_number,
|
||||||
uint8* target) const;
|
uint8* target) const;
|
||||||
@@ -435,6 +436,13 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
|
|||||||
// be linked in). It's up to the protocol compiler to avoid calling this on
|
// be linked in). It's up to the protocol compiler to avoid calling this on
|
||||||
// such ExtensionSets (easy enough since lite messages don't implement
|
// such ExtensionSets (easy enough since lite messages don't implement
|
||||||
// SpaceUsed()).
|
// SpaceUsed()).
|
||||||
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
|
|
||||||
|
// This method just calls SpaceUsedExcludingSelfLong() but it can not be
|
||||||
|
// inlined because the definition of SpaceUsedExcludingSelfLong() is not
|
||||||
|
// included in lite runtime and when an inline method refers to it MSVC
|
||||||
|
// will complain about unresolved symbols when building the lite runtime
|
||||||
|
// as .dll.
|
||||||
int SpaceUsedExcludingSelf() const;
|
int SpaceUsedExcludingSelf() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -457,7 +465,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
|
|||||||
|
|
||||||
virtual bool IsInitialized() const = 0;
|
virtual bool IsInitialized() const = 0;
|
||||||
virtual int ByteSize() const = 0;
|
virtual int ByteSize() const = 0;
|
||||||
virtual int SpaceUsed() const = 0;
|
virtual size_t SpaceUsedLong() const = 0;
|
||||||
|
|
||||||
virtual void MergeFrom(const LazyMessageExtension& other) = 0;
|
virtual void MergeFrom(const LazyMessageExtension& other) = 0;
|
||||||
virtual void Clear() = 0;
|
virtual void Clear() = 0;
|
||||||
@@ -556,7 +564,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
|
|||||||
void Clear();
|
void Clear();
|
||||||
int GetSize() const;
|
int GetSize() const;
|
||||||
void Free();
|
void Free();
|
||||||
int SpaceUsedExcludingSelf() const;
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
};
|
};
|
||||||
typedef std::map<int, Extension> ExtensionMap;
|
typedef std::map<int, Extension> ExtensionMap;
|
||||||
|
|
||||||
@@ -620,7 +628,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
|
|||||||
// class.
|
// class.
|
||||||
|
|
||||||
// Defined in extension_set_heavy.cc.
|
// Defined in extension_set_heavy.cc.
|
||||||
static inline int RepeatedMessage_SpaceUsedExcludingSelf(
|
static inline size_t RepeatedMessage_SpaceUsedExcludingSelfLong(
|
||||||
RepeatedPtrFieldBase* field);
|
RepeatedPtrFieldBase* field);
|
||||||
|
|
||||||
// The Extension struct is small enough to be passed by value, so we use it
|
// The Extension struct is small enough to be passed by value, so we use it
|
||||||
@@ -689,6 +697,10 @@ inline void ExtensionSet::AddString(int number, FieldType type,
|
|||||||
// ExtensionSet* set);
|
// ExtensionSet* set);
|
||||||
// static inline void Add(int number, ConstType value, ExtensionSet* set);
|
// static inline void Add(int number, ConstType value, ExtensionSet* set);
|
||||||
// static inline MutableType Add(int number, ExtensionSet* set);
|
// static inline MutableType Add(int number, ExtensionSet* set);
|
||||||
|
// This is used by the ExtensionIdentifier constructor to register
|
||||||
|
// the extension at dynamic initialization.
|
||||||
|
// template <typename ExtendeeT>
|
||||||
|
// static void Register(int number, FieldType type, bool is_packed);
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// Not all of these methods make sense for all field types. For example, the
|
// Not all of these methods make sense for all field types. For example, the
|
||||||
@@ -720,6 +732,11 @@ class PrimitiveTypeTraits {
|
|||||||
ConstType default_value);
|
ConstType default_value);
|
||||||
static inline void Set(int number, FieldType field_type,
|
static inline void Set(int number, FieldType field_type,
|
||||||
ConstType value, ExtensionSet* set);
|
ConstType value, ExtensionSet* set);
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, false, is_packed);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
@@ -743,6 +760,11 @@ class RepeatedPrimitiveTypeTraits {
|
|||||||
bool is_packed, ExtensionSet* set);
|
bool is_packed, ExtensionSet* set);
|
||||||
|
|
||||||
static const RepeatedFieldType* GetDefaultRepeatedField();
|
static const RepeatedFieldType* GetDefaultRepeatedField();
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, true, is_packed);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_primitive_generic_type_traits_once_init_;
|
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_primitive_generic_type_traits_once_init_;
|
||||||
@@ -840,6 +862,11 @@ class LIBPROTOBUF_EXPORT StringTypeTraits {
|
|||||||
ExtensionSet* set) {
|
ExtensionSet* set) {
|
||||||
return set->MutableString(number, field_type, NULL);
|
return set->MutableString(number, field_type, NULL);
|
||||||
}
|
}
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, false, is_packed);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_string_type_traits_once_init_;
|
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_string_type_traits_once_init_;
|
||||||
@@ -892,6 +919,12 @@ class LIBPROTOBUF_EXPORT RepeatedStringTypeTraits {
|
|||||||
return default_repeated_field_;
|
return default_repeated_field_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, true, is_packed);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void InitializeDefaultRepeatedFields();
|
static void InitializeDefaultRepeatedFields();
|
||||||
static void DestroyDefaultRepeatedFields();
|
static void DestroyDefaultRepeatedFields();
|
||||||
@@ -919,6 +952,11 @@ class EnumTypeTraits {
|
|||||||
GOOGLE_DCHECK(IsValid(value));
|
GOOGLE_DCHECK(IsValid(value));
|
||||||
set->SetEnum(number, field_type, value, NULL);
|
set->SetEnum(number, field_type, value, NULL);
|
||||||
}
|
}
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, false, is_packed, IsValid);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type, bool IsValid(int)>
|
template <typename Type, bool IsValid(int)>
|
||||||
@@ -972,6 +1010,11 @@ class RepeatedEnumTypeTraits {
|
|||||||
return reinterpret_cast<const RepeatedField<Type>*>(
|
return reinterpret_cast<const RepeatedField<Type>*>(
|
||||||
RepeatedPrimitiveTypeTraits<int32>::GetDefaultRepeatedField());
|
RepeatedPrimitiveTypeTraits<int32>::GetDefaultRepeatedField());
|
||||||
}
|
}
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
|
||||||
|
type, true, is_packed, IsValid);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
@@ -1017,6 +1060,12 @@ class MessageTypeTraits {
|
|||||||
return static_cast<Type*>(set->UnsafeArenaReleaseMessage(
|
return static_cast<Type*>(set->UnsafeArenaReleaseMessage(
|
||||||
number, Type::default_instance()));
|
number, Type::default_instance()));
|
||||||
}
|
}
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
|
||||||
|
number, type, false, is_packed,
|
||||||
|
&Type::default_instance());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
@@ -1062,6 +1111,12 @@ class RepeatedMessageTypeTraits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const RepeatedFieldType* GetDefaultRepeatedField();
|
static const RepeatedFieldType* GetDefaultRepeatedField();
|
||||||
|
template <typename ExtendeeT>
|
||||||
|
static void Register(int number, FieldType type, bool is_packed) {
|
||||||
|
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
|
||||||
|
number, type, true, is_packed,
|
||||||
|
&Type::default_instance());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_message_generic_type_traits_once_init_;
|
LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_message_generic_type_traits_once_init_;
|
||||||
@@ -1100,7 +1155,7 @@ template<typename Type> inline
|
|||||||
// parameter, and thus make an instance of ExtensionIdentifier have no
|
// parameter, and thus make an instance of ExtensionIdentifier have no
|
||||||
// actual contents. However, if we did that, then using at extension
|
// actual contents. However, if we did that, then using at extension
|
||||||
// identifier would not necessarily cause the compiler to output any sort
|
// identifier would not necessarily cause the compiler to output any sort
|
||||||
// of reference to any simple defined in the extension's .pb.o file. Some
|
// of reference to any symbol defined in the extension's .pb.o file. Some
|
||||||
// linkers will actually drop object files that are not explicitly referenced,
|
// linkers will actually drop object files that are not explicitly referenced,
|
||||||
// but that would be bad because it would cause this extension to not be
|
// but that would be bad because it would cause this extension to not be
|
||||||
// registered at static initialization, and therefore using it would crash.
|
// registered at static initialization, and therefore using it would crash.
|
||||||
@@ -1113,12 +1168,18 @@ class ExtensionIdentifier {
|
|||||||
typedef ExtendeeType Extendee;
|
typedef ExtendeeType Extendee;
|
||||||
|
|
||||||
ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value)
|
ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value)
|
||||||
: number_(number), default_value_(default_value) {}
|
: number_(number), default_value_(default_value) {
|
||||||
|
Register(number);
|
||||||
|
}
|
||||||
inline int number() const { return number_; }
|
inline int number() const { return number_; }
|
||||||
typename TypeTraits::ConstType default_value() const {
|
typename TypeTraits::ConstType default_value() const {
|
||||||
return default_value_;
|
return default_value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Register(int number) {
|
||||||
|
TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int number_;
|
const int number_;
|
||||||
typename TypeTraits::ConstType default_value_;
|
typename TypeTraits::ConstType default_value_;
|
||||||
|
|||||||
+43
-30
@@ -35,11 +35,14 @@
|
|||||||
// Contains methods defined in extension_set.h which cannot be part of the
|
// Contains methods defined in extension_set.h which cannot be part of the
|
||||||
// lite library because they use descriptors or reflection.
|
// lite library because they use descriptors or reflection.
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||||
|
#include <google/protobuf/descriptor.pb.h>
|
||||||
#include <google/protobuf/descriptor.h>
|
#include <google/protobuf/descriptor.h>
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h>
|
||||||
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
@@ -340,31 +343,35 @@ bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ExtensionSet::SpaceUsedExcludingSelf() const {
|
int ExtensionSet::SpaceUsedExcludingSelf() const {
|
||||||
int total_size =
|
return internal::FromIntSize(SpaceUsedExcludingSelfLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t ExtensionSet::SpaceUsedExcludingSelfLong() const {
|
||||||
|
size_t total_size =
|
||||||
extensions_.size() * sizeof(ExtensionMap::value_type);
|
extensions_.size() * sizeof(ExtensionMap::value_type);
|
||||||
for (ExtensionMap::const_iterator iter = extensions_.begin(),
|
for (ExtensionMap::const_iterator iter = extensions_.begin(),
|
||||||
end = extensions_.end();
|
end = extensions_.end();
|
||||||
iter != end;
|
iter != end;
|
||||||
++iter) {
|
++iter) {
|
||||||
total_size += iter->second.SpaceUsedExcludingSelf();
|
total_size += iter->second.SpaceUsedExcludingSelfLong();
|
||||||
}
|
}
|
||||||
return total_size;
|
return total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int ExtensionSet::RepeatedMessage_SpaceUsedExcludingSelf(
|
inline size_t ExtensionSet::RepeatedMessage_SpaceUsedExcludingSelfLong(
|
||||||
RepeatedPtrFieldBase* field) {
|
RepeatedPtrFieldBase* field) {
|
||||||
return field->SpaceUsedExcludingSelf<GenericTypeHandler<Message> >();
|
return field->SpaceUsedExcludingSelfLong<GenericTypeHandler<Message> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExtensionSet::Extension::SpaceUsedExcludingSelf() const {
|
size_t ExtensionSet::Extension::SpaceUsedExcludingSelfLong() const {
|
||||||
int total_size = 0;
|
size_t total_size = 0;
|
||||||
if (is_repeated) {
|
if (is_repeated) {
|
||||||
switch (cpp_type(type)) {
|
switch (cpp_type(type)) {
|
||||||
#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
|
#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
|
||||||
case FieldDescriptor::CPPTYPE_##UPPERCASE: \
|
case FieldDescriptor::CPPTYPE_##UPPERCASE: \
|
||||||
total_size += sizeof(*repeated_##LOWERCASE##_value) + \
|
total_size += sizeof(*repeated_##LOWERCASE##_value) + \
|
||||||
repeated_##LOWERCASE##_value->SpaceUsedExcludingSelf();\
|
repeated_##LOWERCASE##_value->SpaceUsedExcludingSelfLong(); \
|
||||||
break
|
break
|
||||||
|
|
||||||
HANDLE_TYPE( INT32, int32);
|
HANDLE_TYPE( INT32, int32);
|
||||||
HANDLE_TYPE( INT64, int64);
|
HANDLE_TYPE( INT64, int64);
|
||||||
@@ -379,24 +386,25 @@ int ExtensionSet::Extension::SpaceUsedExcludingSelf() const {
|
|||||||
|
|
||||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
// repeated_message_value is actually a RepeatedPtrField<MessageLite>,
|
// repeated_message_value is actually a RepeatedPtrField<MessageLite>,
|
||||||
// but MessageLite has no SpaceUsed(), so we must directly call
|
// but MessageLite has no SpaceUsedLong(), so we must directly call
|
||||||
// RepeatedPtrFieldBase::SpaceUsedExcludingSelf() with a different type
|
// RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() with a different
|
||||||
// handler.
|
// type handler.
|
||||||
total_size += sizeof(*repeated_message_value) +
|
total_size +=
|
||||||
RepeatedMessage_SpaceUsedExcludingSelf(repeated_message_value);
|
sizeof(*repeated_message_value) +
|
||||||
|
RepeatedMessage_SpaceUsedExcludingSelfLong(repeated_message_value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (cpp_type(type)) {
|
switch (cpp_type(type)) {
|
||||||
case FieldDescriptor::CPPTYPE_STRING:
|
case FieldDescriptor::CPPTYPE_STRING:
|
||||||
total_size += sizeof(*string_value) +
|
total_size += sizeof(*string_value) +
|
||||||
StringSpaceUsedExcludingSelf(*string_value);
|
StringSpaceUsedExcludingSelfLong(*string_value);
|
||||||
break;
|
break;
|
||||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
if (is_lazy) {
|
if (is_lazy) {
|
||||||
total_size += lazymessage_value->SpaceUsed();
|
total_size += lazymessage_value->SpaceUsedLong();
|
||||||
} else {
|
} else {
|
||||||
total_size += down_cast<Message*>(message_value)->SpaceUsed();
|
total_size += down_cast<Message*>(message_value)->SpaceUsedLong();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -413,12 +421,16 @@ uint8* ExtensionSet::SerializeWithCachedSizesToArray(int start_field_number,
|
|||||||
int end_field_number,
|
int end_field_number,
|
||||||
uint8* target) const {
|
uint8* target) const {
|
||||||
return InternalSerializeWithCachedSizesToArray(
|
return InternalSerializeWithCachedSizesToArray(
|
||||||
start_field_number, end_field_number, false, target);
|
start_field_number, end_field_number,
|
||||||
|
google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
|
||||||
|
target);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
|
uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
|
||||||
uint8* target) const {
|
uint8* target) const {
|
||||||
return InternalSerializeMessageSetWithCachedSizesToArray(false, target);
|
return InternalSerializeMessageSetWithCachedSizesToArray(
|
||||||
|
google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
|
||||||
|
target);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(
|
uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(
|
||||||
@@ -479,10 +491,10 @@ uint8* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(
|
|||||||
HANDLE_TYPE( ENUM, Enum, enum);
|
HANDLE_TYPE( ENUM, Enum, enum);
|
||||||
#undef HANDLE_TYPE
|
#undef HANDLE_TYPE
|
||||||
|
|
||||||
case WireFormatLite::TYPE_STRING:
|
case FieldDescriptor::TYPE_STRING:
|
||||||
case WireFormatLite::TYPE_BYTES:
|
case FieldDescriptor::TYPE_BYTES:
|
||||||
case WireFormatLite::TYPE_GROUP:
|
case FieldDescriptor::TYPE_GROUP:
|
||||||
case WireFormatLite::TYPE_MESSAGE:
|
case FieldDescriptor::TYPE_MESSAGE:
|
||||||
GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
|
GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -587,11 +599,12 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
|
|||||||
WireFormatLite::kMessageSetTypeIdNumber, number, target);
|
WireFormatLite::kMessageSetTypeIdNumber, number, target);
|
||||||
// Write message.
|
// Write message.
|
||||||
if (is_lazy) {
|
if (is_lazy) {
|
||||||
target = lazymessage_value->WriteMessageToArray(
|
target = lazymessage_value->InternalWriteMessageToArray(
|
||||||
WireFormatLite::kMessageSetMessageNumber, target);
|
WireFormatLite::kMessageSetMessageNumber, deterministic, target);
|
||||||
} else {
|
} else {
|
||||||
target = WireFormatLite::WriteMessageToArray(
|
target = WireFormatLite::InternalWriteMessageToArray(
|
||||||
WireFormatLite::kMessageSetMessageNumber, *message_value, target);
|
WireFormatLite::kMessageSetMessageNumber, *message_value, deterministic,
|
||||||
|
target);
|
||||||
}
|
}
|
||||||
// End group.
|
// End group.
|
||||||
target = io::CodedOutputStream::WriteTagToArray(
|
target = io::CodedOutputStream::WriteTagToArray(
|
||||||
@@ -656,7 +669,7 @@ bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input,
|
|||||||
string message_data;
|
string message_data;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const uint32 tag = input->ReadTag();
|
const uint32 tag = input->ReadTagNoLastTag();
|
||||||
if (tag == 0) return false;
|
if (tag == 0) return false;
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
|
|||||||
+159
-216
@@ -1,7 +1,6 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: google/protobuf/field_mask.proto
|
// source: google/protobuf/field_mask.proto
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include <google/protobuf/field_mask.pb.h>
|
#include <google/protobuf/field_mask.pb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -15,136 +14,131 @@
|
|||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
|
// This is a temporary google only hack
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
#include "third_party/protobuf/version.h"
|
||||||
|
#endif
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
class FieldMaskDefaultTypeInternal {
|
||||||
|
public:
|
||||||
|
::google::protobuf::internal::ExplicitlyConstructed<FieldMask>
|
||||||
|
_instance;
|
||||||
|
} _FieldMask_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
|
||||||
|
void InitDefaultsFieldMaskImpl() {
|
||||||
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
|
||||||
|
#else
|
||||||
|
::google::protobuf::internal::InitProtobufDefaults();
|
||||||
|
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
{
|
||||||
|
void* ptr = &::google::protobuf::_FieldMask_default_instance_;
|
||||||
|
new (ptr) ::google::protobuf::FieldMask();
|
||||||
|
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
||||||
|
}
|
||||||
|
::google::protobuf::FieldMask::InitAsDefaultInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDefaultsFieldMask() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsFieldMaskImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
::google::protobuf::Metadata file_level_metadata[1];
|
||||||
|
|
||||||
|
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
~0u, // no _has_bits_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, _internal_metadata_),
|
||||||
|
~0u, // no _extensions_
|
||||||
|
~0u, // no _oneof_case_
|
||||||
|
~0u, // no _weak_field_map_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FieldMask, paths_),
|
||||||
|
};
|
||||||
|
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
{ 0, -1, sizeof(::google::protobuf::FieldMask)},
|
||||||
|
};
|
||||||
|
|
||||||
|
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||||
|
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FieldMask_default_instance_),
|
||||||
|
};
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptors() {
|
||||||
|
AddDescriptors();
|
||||||
|
::google::protobuf::MessageFactory* factory = NULL;
|
||||||
|
AssignDescriptors(
|
||||||
|
"google/protobuf/field_mask.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||||
|
file_level_metadata, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptorsOnce() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) {
|
||||||
|
protobuf_AssignDescriptorsOnce();
|
||||||
|
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptorsImpl() {
|
||||||
|
InitDefaults();
|
||||||
|
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
"\n google/protobuf/field_mask.proto\022\017goog"
|
||||||
|
"le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
|
||||||
|
"\211\001\n\023com.google.protobufB\016FieldMaskProtoP"
|
||||||
|
"\001Z9google.golang.org/genproto/protobuf/f"
|
||||||
|
"ield_mask;field_mask\242\002\003GPB\252\002\036Google.Prot"
|
||||||
|
"obuf.WellKnownTypesb\006proto3"
|
||||||
|
};
|
||||||
|
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||||
|
descriptor, 227);
|
||||||
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
|
"google/protobuf/field_mask.proto", &protobuf_RegisterTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptors() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||||
|
}
|
||||||
|
// Force AddDescriptors() to be called at dynamic initialization time.
|
||||||
|
struct StaticDescriptorInitializer {
|
||||||
|
StaticDescriptorInitializer() {
|
||||||
|
AddDescriptors();
|
||||||
|
}
|
||||||
|
} static_descriptor_initializer;
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
FieldMask_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"google/protobuf/field_mask.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
FieldMask_descriptor_ = file->message_type(0);
|
|
||||||
static const int FieldMask_offsets_[1] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),
|
|
||||||
};
|
|
||||||
FieldMask_reflection_ =
|
|
||||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
|
||||||
FieldMask_descriptor_,
|
|
||||||
FieldMask::internal_default_instance(),
|
|
||||||
FieldMask_offsets_,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
sizeof(FieldMask),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
FieldMask_descriptor_, FieldMask::internal_default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() {
|
|
||||||
FieldMask_default_instance_.Shutdown();
|
|
||||||
delete FieldMask_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
::google::protobuf::internal::GetEmptyString();
|
|
||||||
FieldMask_default_instance_.DefaultConstruct();
|
|
||||||
FieldMask_default_instance_.get_mutable()->InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_);
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_,
|
|
||||||
&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
|
|
||||||
}
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n google/protobuf/field_mask.proto\022\017goog"
|
|
||||||
"le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
|
|
||||||
"N\n\023com.google.protobufB\016FieldMaskProtoP\001"
|
|
||||||
"\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb"
|
|
||||||
"\006proto3", 167);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"google/protobuf/field_mask.proto", &protobuf_RegisterTypes);
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_);
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_,
|
|
||||||
&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto {
|
|
||||||
StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
static void MergeFromFail(int line) {
|
|
||||||
::google::protobuf::internal::MergeFromFail(__FILE__, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
void FieldMask::InitAsDefaultInstance() {
|
||||||
|
}
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
const int FieldMask::kPathsFieldNumber;
|
const int FieldMask::kPathsFieldNumber;
|
||||||
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
|
|
||||||
FieldMask::FieldMask()
|
FieldMask::FieldMask()
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||||
if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
|
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||||
|
::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMask();
|
||||||
|
}
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
// @@protoc_insertion_point(constructor:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(constructor:google.protobuf.FieldMask)
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldMask::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
FieldMask::FieldMask(const FieldMask& from)
|
FieldMask::FieldMask(const FieldMask& from)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(NULL) {
|
_internal_metadata_(NULL),
|
||||||
SharedCtor();
|
paths_(from.paths_),
|
||||||
UnsafeMergeFrom(from);
|
_cached_size_(0) {
|
||||||
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,17 +160,15 @@ void FieldMask::SetCachedSize(int size) const {
|
|||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||||
}
|
}
|
||||||
const ::google::protobuf::Descriptor* FieldMask::descriptor() {
|
const ::google::protobuf::Descriptor* FieldMask::descriptor() {
|
||||||
protobuf_AssignDescriptorsOnce();
|
::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
return FieldMask_descriptor_;
|
return ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FieldMask& FieldMask::default_instance() {
|
const FieldMask& FieldMask::default_instance() {
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
|
::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMask();
|
||||||
return *internal_default_instance();
|
return *internal_default_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_;
|
|
||||||
|
|
||||||
FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {
|
FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {
|
||||||
FieldMask* n = new FieldMask;
|
FieldMask* n = new FieldMask;
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
@@ -187,7 +179,12 @@ FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {
|
|||||||
|
|
||||||
void FieldMask::Clear() {
|
void FieldMask::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
paths_.Clear();
|
paths_.Clear();
|
||||||
|
_internal_metadata_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FieldMask::MergePartialFromCodedStream(
|
bool FieldMask::MergePartialFromCodedStream(
|
||||||
@@ -196,37 +193,34 @@ bool FieldMask::MergePartialFromCodedStream(
|
|||||||
::google::protobuf::uint32 tag;
|
::google::protobuf::uint32 tag;
|
||||||
// @@protoc_insertion_point(parse_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(parse_start:google.protobuf.FieldMask)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
|
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
||||||
tag = p.first;
|
tag = p.first;
|
||||||
if (!p.second) goto handle_unusual;
|
if (!p.second) goto handle_unusual;
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||||
// repeated string paths = 1;
|
// repeated string paths = 1;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (tag == 10) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
parse_paths:
|
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
||||||
input, this->add_paths()));
|
input, this->add_paths()));
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->paths(this->paths_size() - 1).data(),
|
this->paths(this->paths_size() - 1).data(),
|
||||||
this->paths(this->paths_size() - 1).length(),
|
static_cast<int>(this->paths(this->paths_size() - 1).length()),
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
::google::protobuf::internal::WireFormatLite::PARSE,
|
||||||
"google.protobuf.FieldMask.paths"));
|
"google.protobuf.FieldMask.paths"));
|
||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectTag(10)) goto parse_paths;
|
|
||||||
if (input->ExpectAtEnd()) goto success;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if (tag == 0 ||
|
if (tag == 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
|
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||||
|
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,16 +237,23 @@ failure:
|
|||||||
void FieldMask::SerializeWithCachedSizes(
|
void FieldMask::SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
::google::protobuf::io::CodedOutputStream* output) const {
|
||||||
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
// repeated string paths = 1;
|
// repeated string paths = 1;
|
||||||
for (int i = 0; i < this->paths_size(); i++) {
|
for (int i = 0, n = this->paths_size(); i < n; i++) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->paths(i).data(), this->paths(i).length(),
|
this->paths(i).data(), static_cast<int>(this->paths(i).length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.FieldMask.paths");
|
"google.protobuf.FieldMask.paths");
|
||||||
::google::protobuf::internal::WireFormatLite::WriteString(
|
::google::protobuf::internal::WireFormatLite::WriteString(
|
||||||
1, this->paths(i), output);
|
1, this->paths(i), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_end:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(serialize_end:google.protobuf.FieldMask)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,16 +261,23 @@ void FieldMask::SerializeWithCachedSizes(
|
|||||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||||
(void)deterministic; // Unused
|
(void)deterministic; // Unused
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
// repeated string paths = 1;
|
// repeated string paths = 1;
|
||||||
for (int i = 0; i < this->paths_size(); i++) {
|
for (int i = 0, n = this->paths_size(); i < n; i++) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->paths(i).data(), this->paths(i).length(),
|
this->paths(i).data(), static_cast<int>(this->paths(i).length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.FieldMask.paths");
|
"google.protobuf.FieldMask.paths");
|
||||||
target = ::google::protobuf::internal::WireFormatLite::
|
target = ::google::protobuf::internal::WireFormatLite::
|
||||||
WriteStringToArray(1, this->paths(i), target);
|
WriteStringToArray(1, this->paths(i), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -278,10 +286,15 @@ size_t FieldMask::ByteSizeLong() const {
|
|||||||
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
total_size +=
|
||||||
|
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
|
||||||
|
}
|
||||||
// repeated string paths = 1;
|
// repeated string paths = 1;
|
||||||
total_size += 1 *
|
total_size += 1 *
|
||||||
::google::protobuf::internal::FromIntSize(this->paths_size());
|
::google::protobuf::internal::FromIntSize(this->paths_size());
|
||||||
for (int i = 0; i < this->paths_size(); i++) {
|
for (int i = 0, n = this->paths_size(); i < n; i++) {
|
||||||
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
|
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
|
||||||
this->paths(i));
|
this->paths(i));
|
||||||
}
|
}
|
||||||
@@ -295,7 +308,7 @@ size_t FieldMask::ByteSizeLong() const {
|
|||||||
|
|
||||||
void FieldMask::MergeFrom(const ::google::protobuf::Message& from) {
|
void FieldMask::MergeFrom(const ::google::protobuf::Message& from) {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask)
|
||||||
if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
const FieldMask* source =
|
const FieldMask* source =
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>(
|
::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>(
|
||||||
&from);
|
&from);
|
||||||
@@ -304,22 +317,18 @@ void FieldMask::MergeFrom(const ::google::protobuf::Message& from) {
|
|||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||||
} else {
|
} else {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask)
|
||||||
UnsafeMergeFrom(*source);
|
MergeFrom(*source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldMask::MergeFrom(const FieldMask& from) {
|
void FieldMask::MergeFrom(const FieldMask& from) {
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask)
|
||||||
if (GOOGLE_PREDICT_TRUE(&from != this)) {
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
} else {
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
MergeFromFail(__LINE__);
|
(void) cached_has_bits;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FieldMask::UnsafeMergeFrom(const FieldMask& from) {
|
paths_.MergeFrom(from.paths_);
|
||||||
GOOGLE_DCHECK(&from != this);
|
|
||||||
paths_.UnsafeMergeFrom(from.paths_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldMask::CopyFrom(const ::google::protobuf::Message& from) {
|
void FieldMask::CopyFrom(const ::google::protobuf::Message& from) {
|
||||||
@@ -333,11 +342,10 @@ void FieldMask::CopyFrom(const FieldMask& from) {
|
|||||||
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask)
|
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
UnsafeMergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FieldMask::IsInitialized() const {
|
bool FieldMask::IsInitialized() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,84 +354,19 @@ void FieldMask::Swap(FieldMask* other) {
|
|||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
void FieldMask::InternalSwap(FieldMask* other) {
|
void FieldMask::InternalSwap(FieldMask* other) {
|
||||||
paths_.UnsafeArenaSwap(&other->paths_);
|
using std::swap;
|
||||||
|
paths_.InternalSwap(&other->paths_);
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
swap(_cached_size_, other->_cached_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::Metadata FieldMask::GetMetadata() const {
|
::google::protobuf::Metadata FieldMask::GetMetadata() const {
|
||||||
protobuf_AssignDescriptorsOnce();
|
protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
::google::protobuf::Metadata metadata;
|
return ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[kIndexInFileMessages];
|
||||||
metadata.descriptor = FieldMask_descriptor_;
|
|
||||||
metadata.reflection = FieldMask_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// FieldMask
|
|
||||||
|
|
||||||
// repeated string paths = 1;
|
|
||||||
int FieldMask::paths_size() const {
|
|
||||||
return paths_.size();
|
|
||||||
}
|
|
||||||
void FieldMask::clear_paths() {
|
|
||||||
paths_.Clear();
|
|
||||||
}
|
|
||||||
const ::std::string& FieldMask::paths(int index) const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths)
|
|
||||||
return paths_.Get(index);
|
|
||||||
}
|
|
||||||
::std::string* FieldMask::mutable_paths(int index) {
|
|
||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths)
|
|
||||||
return paths_.Mutable(index);
|
|
||||||
}
|
|
||||||
void FieldMask::set_paths(int index, const ::std::string& value) {
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
|
|
||||||
paths_.Mutable(index)->assign(value);
|
|
||||||
}
|
|
||||||
void FieldMask::set_paths(int index, const char* value) {
|
|
||||||
paths_.Mutable(index)->assign(value);
|
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
|
|
||||||
}
|
|
||||||
void FieldMask::set_paths(int index, const char* value, size_t size) {
|
|
||||||
paths_.Mutable(index)->assign(
|
|
||||||
reinterpret_cast<const char*>(value), size);
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths)
|
|
||||||
}
|
|
||||||
::std::string* FieldMask::add_paths() {
|
|
||||||
// @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths)
|
|
||||||
return paths_.Add();
|
|
||||||
}
|
|
||||||
void FieldMask::add_paths(const ::std::string& value) {
|
|
||||||
paths_.Add()->assign(value);
|
|
||||||
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
|
|
||||||
}
|
|
||||||
void FieldMask::add_paths(const char* value) {
|
|
||||||
paths_.Add()->assign(value);
|
|
||||||
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
|
|
||||||
}
|
|
||||||
void FieldMask::add_paths(const char* value, size_t size) {
|
|
||||||
paths_.Add()->assign(reinterpret_cast<const char*>(value), size);
|
|
||||||
// @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths)
|
|
||||||
}
|
|
||||||
const ::google::protobuf::RepeatedPtrField< ::std::string>&
|
|
||||||
FieldMask::paths() const {
|
|
||||||
// @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths)
|
|
||||||
return paths_;
|
|
||||||
}
|
|
||||||
::google::protobuf::RepeatedPtrField< ::std::string>*
|
|
||||||
FieldMask::mutable_paths() {
|
|
||||||
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths)
|
|
||||||
return &paths_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const FieldMask* FieldMask::internal_default_instance() {
|
|
||||||
return &FieldMask_default_instance_.get();
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
|||||||
+97
-44
@@ -8,37 +8,55 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[1];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsFieldMaskImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsFieldMask();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsFieldMask();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
|
|
||||||
class FieldMask;
|
class FieldMask;
|
||||||
|
class FieldMaskDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -53,53 +71,72 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
FieldMask(FieldMask&& from) noexcept
|
||||||
|
: FieldMask() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FieldMask& operator=(FieldMask&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const FieldMask& default_instance();
|
static const FieldMask& default_instance();
|
||||||
|
|
||||||
static const FieldMask* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const FieldMask* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const FieldMask*>(
|
||||||
|
&_FieldMask_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
void Swap(FieldMask* other);
|
void Swap(FieldMask* other);
|
||||||
|
friend void swap(FieldMask& a, FieldMask& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline FieldMask* New() const { return New(NULL); }
|
inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
FieldMask* New(::google::protobuf::Arena* arena) const;
|
FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const FieldMask& from);
|
void CopyFrom(const FieldMask& from);
|
||||||
void MergeFrom(const FieldMask& from);
|
void MergeFrom(const FieldMask& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(FieldMask* other);
|
void InternalSwap(FieldMask* other);
|
||||||
void UnsafeMergeFrom(const FieldMask& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
@@ -112,10 +149,16 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
|
|||||||
const ::std::string& paths(int index) const;
|
const ::std::string& paths(int index) const;
|
||||||
::std::string* mutable_paths(int index);
|
::std::string* mutable_paths(int index);
|
||||||
void set_paths(int index, const ::std::string& value);
|
void set_paths(int index, const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_paths(int index, ::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_paths(int index, const char* value);
|
void set_paths(int index, const char* value);
|
||||||
void set_paths(int index, const char* value, size_t size);
|
void set_paths(int index, const char* value, size_t size);
|
||||||
::std::string* add_paths();
|
::std::string* add_paths();
|
||||||
void add_paths(const ::std::string& value);
|
void add_paths(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void add_paths(::std::string&& value);
|
||||||
|
#endif
|
||||||
void add_paths(const char* value);
|
void add_paths(const char* value);
|
||||||
void add_paths(const char* value, size_t size);
|
void add_paths(const char* value, size_t size);
|
||||||
const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const;
|
const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const;
|
||||||
@@ -127,21 +170,18 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
|
|||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
::google::protobuf::RepeatedPtrField< ::std::string> paths_;
|
::google::protobuf::RepeatedPtrField< ::std::string> paths_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaultsFieldMaskImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// FieldMask
|
// FieldMask
|
||||||
|
|
||||||
// repeated string paths = 1;
|
// repeated string paths = 1;
|
||||||
@@ -163,7 +203,14 @@ inline void FieldMask::set_paths(int index, const ::std::string& value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
|
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
|
||||||
paths_.Mutable(index)->assign(value);
|
paths_.Mutable(index)->assign(value);
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void FieldMask::set_paths(int index, ::std::string&& value) {
|
||||||
|
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
|
||||||
|
paths_.Mutable(index)->assign(std::move(value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void FieldMask::set_paths(int index, const char* value) {
|
inline void FieldMask::set_paths(int index, const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
paths_.Mutable(index)->assign(value);
|
paths_.Mutable(index)->assign(value);
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
|
||||||
}
|
}
|
||||||
@@ -180,7 +227,14 @@ inline void FieldMask::add_paths(const ::std::string& value) {
|
|||||||
paths_.Add()->assign(value);
|
paths_.Add()->assign(value);
|
||||||
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
|
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void FieldMask::add_paths(::std::string&& value) {
|
||||||
|
paths_.Add(std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void FieldMask::add_paths(const char* value) {
|
inline void FieldMask::add_paths(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
paths_.Add()->assign(value);
|
paths_.Add()->assign(value);
|
||||||
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
|
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
|
||||||
}
|
}
|
||||||
@@ -199,10 +253,9 @@ FieldMask::mutable_paths() {
|
|||||||
return &paths_;
|
return &paths_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const FieldMask* FieldMask::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &FieldMask_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
|
|||||||
+399
-316
File diff suppressed because it is too large
Load Diff
+207
-150
@@ -61,7 +61,15 @@ namespace protobuf {
|
|||||||
class DescriptorPool;
|
class DescriptorPool;
|
||||||
class MapKey;
|
class MapKey;
|
||||||
class MapValueRef;
|
class MapValueRef;
|
||||||
}
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|
||||||
|
namespace protobuf {
|
||||||
|
namespace flat {
|
||||||
|
class MetadataBuilder;
|
||||||
|
} // namespace flat
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -72,6 +80,158 @@ class GeneratedMessageReflection;
|
|||||||
|
|
||||||
// Defined in other files.
|
// Defined in other files.
|
||||||
class ExtensionSet; // extension_set.h
|
class ExtensionSet; // extension_set.h
|
||||||
|
class WeakFieldMap; // weak_field_map.h
|
||||||
|
|
||||||
|
// This struct describes the internal layout of the message, hence this is
|
||||||
|
// used to act on the message reflectively.
|
||||||
|
// default_instance: The default instance of the message. This is only
|
||||||
|
// used to obtain pointers to default instances of embedded
|
||||||
|
// messages, which GetMessage() will return if the particular
|
||||||
|
// sub-message has not been initialized yet. (Thus, all
|
||||||
|
// embedded message fields *must* have non-NULL pointers
|
||||||
|
// in the default instance.)
|
||||||
|
// offsets: An array of ints giving the byte offsets.
|
||||||
|
// For each oneof or weak field, the offset is relative to the
|
||||||
|
// default_instance. These can be computed at compile time
|
||||||
|
// using the
|
||||||
|
// GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET()
|
||||||
|
// macro. For each none oneof field, the offset is related to
|
||||||
|
// the start of the message object. These can be computed at
|
||||||
|
// compile time using the
|
||||||
|
// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro.
|
||||||
|
// Besides offsets for all fields, this array also contains
|
||||||
|
// offsets for oneof unions. The offset of the i-th oneof union
|
||||||
|
// is offsets[descriptor->field_count() + i].
|
||||||
|
// has_bit_indices: Mapping from field indexes to their index in the has
|
||||||
|
// bit array.
|
||||||
|
// has_bits_offset: Offset in the message of an array of uint32s of size
|
||||||
|
// descriptor->field_count()/32, rounded up. This is a
|
||||||
|
// bitfield where each bit indicates whether or not the
|
||||||
|
// corresponding field of the message has been initialized.
|
||||||
|
// The bit for field index i is obtained by the expression:
|
||||||
|
// has_bits[i / 32] & (1 << (i % 32))
|
||||||
|
// unknown_fields_offset: Offset in the message of the UnknownFieldSet for
|
||||||
|
// the message.
|
||||||
|
// extensions_offset: Offset in the message of the ExtensionSet for the
|
||||||
|
// message, or -1 if the message type has no extension
|
||||||
|
// ranges.
|
||||||
|
// oneof_case_offset: Offset in the message of an array of uint32s of
|
||||||
|
// size descriptor->oneof_decl_count(). Each uint32
|
||||||
|
// indicates what field is set for each oneof.
|
||||||
|
// object_size: The size of a message object of this type, as measured
|
||||||
|
// by sizeof().
|
||||||
|
// arena_offset: If a message doesn't have a unknown_field_set that stores
|
||||||
|
// the arena, it must have a direct pointer to the arena.
|
||||||
|
// weak_field_map_offset: If the message proto has weak fields, this is the
|
||||||
|
// offset of _weak_field_map_ in the generated proto. Otherwise
|
||||||
|
// -1.
|
||||||
|
struct ReflectionSchema {
|
||||||
|
public:
|
||||||
|
// Size of a google::protobuf::Message object of this type.
|
||||||
|
uint32 GetObjectSize() const { return static_cast<uint32>(object_size_); }
|
||||||
|
|
||||||
|
// Offset of a non-oneof field. Getting a field offset is slightly more
|
||||||
|
// efficient when we know statically that it is not a oneof field.
|
||||||
|
uint32 GetFieldOffsetNonOneof(const FieldDescriptor* field) const {
|
||||||
|
GOOGLE_DCHECK(!field->containing_oneof());
|
||||||
|
return offsets_[field->index()];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset of any field.
|
||||||
|
uint32 GetFieldOffset(const FieldDescriptor* field) const {
|
||||||
|
if (field->containing_oneof()) {
|
||||||
|
size_t offset =
|
||||||
|
static_cast<size_t>(field->containing_type()->field_count() +
|
||||||
|
field->containing_oneof()->index());
|
||||||
|
return offsets_[offset];
|
||||||
|
} else {
|
||||||
|
return GetFieldOffsetNonOneof(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const {
|
||||||
|
return static_cast<uint32>(oneof_case_offset_) +
|
||||||
|
static_cast<uint32>(
|
||||||
|
static_cast<size_t>(oneof_descriptor->index()) * sizeof(uint32));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasHasbits() const { return has_bits_offset_ != -1; }
|
||||||
|
|
||||||
|
// Bit index within the bit array of hasbits. Bit order is low-to-high.
|
||||||
|
uint32 HasBitIndex(const FieldDescriptor* field) const {
|
||||||
|
GOOGLE_DCHECK(HasHasbits());
|
||||||
|
return has_bit_indices_[field->index()];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Byte offset of the hasbits array.
|
||||||
|
uint32 HasBitsOffset() const {
|
||||||
|
GOOGLE_DCHECK(HasHasbits());
|
||||||
|
return static_cast<uint32>(has_bits_offset_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The offset of the InternalMetadataWithArena member.
|
||||||
|
// For Lite this will actually be an InternalMetadataWithArenaLite.
|
||||||
|
// The schema doesn't contain enough information to distinguish between
|
||||||
|
// these two cases.
|
||||||
|
uint32 GetMetadataOffset() const {
|
||||||
|
return static_cast<uint32>(metadata_offset_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whether this message has an ExtensionSet.
|
||||||
|
bool HasExtensionSet() const { return extensions_offset_ != -1; }
|
||||||
|
|
||||||
|
// The offset of the ExtensionSet in this message.
|
||||||
|
uint32 GetExtensionSetOffset() const {
|
||||||
|
GOOGLE_DCHECK(HasExtensionSet());
|
||||||
|
return static_cast<uint32>(extensions_offset_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The off set of WeakFieldMap when the message contains weak fields.
|
||||||
|
// The default is 0 for now.
|
||||||
|
int GetWeakFieldMapOffset() const { return weak_field_map_offset_; }
|
||||||
|
|
||||||
|
bool IsDefaultInstance(const Message& message) const {
|
||||||
|
return &message == default_instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a pointer to the default value for this field. The size and type
|
||||||
|
// of the underlying data depends on the field's type.
|
||||||
|
const void *GetFieldDefault(const FieldDescriptor* field) const {
|
||||||
|
return reinterpret_cast<const uint8*>(default_instance_) +
|
||||||
|
offsets_[field->index()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool HasWeakFields() const { return weak_field_map_offset_ > 0; }
|
||||||
|
|
||||||
|
// These members are intended to be private, but we cannot actually make them
|
||||||
|
// private because this prevents us from using aggregate initialization of
|
||||||
|
// them, ie.
|
||||||
|
//
|
||||||
|
// ReflectionSchema schema = {a, b, c, d, e, ...};
|
||||||
|
// private:
|
||||||
|
const Message* default_instance_;
|
||||||
|
const uint32* offsets_;
|
||||||
|
const uint32* has_bit_indices_;
|
||||||
|
int has_bits_offset_;
|
||||||
|
int metadata_offset_;
|
||||||
|
int extensions_offset_;
|
||||||
|
int oneof_case_offset_;
|
||||||
|
int object_size_;
|
||||||
|
int weak_field_map_offset_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Structs that the code generator emits directly to describe a message.
|
||||||
|
// These should never used directly except to build a ReflectionSchema
|
||||||
|
// object.
|
||||||
|
//
|
||||||
|
// EXPERIMENTAL: these are changing rapidly, and may completely disappear
|
||||||
|
// or merge with ReflectionSchema.
|
||||||
|
struct MigrationSchema {
|
||||||
|
int32 offsets_index;
|
||||||
|
int32 has_bit_indices_index;
|
||||||
|
int object_size;
|
||||||
|
};
|
||||||
|
|
||||||
// THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use
|
// THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use
|
||||||
// by generated code. This class is just a big hack that reduces code
|
// by generated code. This class is just a big hack that reduces code
|
||||||
@@ -97,115 +257,29 @@ class ExtensionSet; // extension_set.h
|
|||||||
// of whatever type the individual field would be. Strings and
|
// of whatever type the individual field would be. Strings and
|
||||||
// Messages use RepeatedPtrFields while everything else uses
|
// Messages use RepeatedPtrFields while everything else uses
|
||||||
// RepeatedFields.
|
// RepeatedFields.
|
||||||
class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Reflection {
|
||||||
public:
|
public:
|
||||||
// Constructs a GeneratedMessageReflection.
|
// Constructs a GeneratedMessageReflection.
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// descriptor: The descriptor for the message type being implemented.
|
// descriptor: The descriptor for the message type being implemented.
|
||||||
// default_instance: The default instance of the message. This is only
|
// schema: The description of the internal guts of the message.
|
||||||
// used to obtain pointers to default instances of embedded
|
|
||||||
// messages, which GetMessage() will return if the particular
|
|
||||||
// sub-message has not been initialized yet. (Thus, all
|
|
||||||
// embedded message fields *must* have non-NULL pointers
|
|
||||||
// in the default instance.)
|
|
||||||
// offsets: An array of ints giving the byte offsets, relative to
|
|
||||||
// the start of the message object, of each field. These can
|
|
||||||
// be computed at compile time using the
|
|
||||||
// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined
|
|
||||||
// below.
|
|
||||||
// has_bits_offset: Offset in the message of an array of uint32s of size
|
|
||||||
// descriptor->field_count()/32, rounded up. This is a
|
|
||||||
// bitfield where each bit indicates whether or not the
|
|
||||||
// corresponding field of the message has been initialized.
|
|
||||||
// The bit for field index i is obtained by the expression:
|
|
||||||
// has_bits[i / 32] & (1 << (i % 32))
|
|
||||||
// unknown_fields_offset: Offset in the message of the UnknownFieldSet for
|
|
||||||
// the message.
|
|
||||||
// extensions_offset: Offset in the message of the ExtensionSet for the
|
|
||||||
// message, or -1 if the message type has no extension
|
|
||||||
// ranges.
|
|
||||||
// pool: DescriptorPool to search for extension definitions. Only
|
// pool: DescriptorPool to search for extension definitions. Only
|
||||||
// used by FindKnownExtensionByName() and
|
// used by FindKnownExtensionByName() and
|
||||||
// FindKnownExtensionByNumber().
|
// FindKnownExtensionByNumber().
|
||||||
// factory: MessageFactory to use to construct extension messages.
|
// factory: MessageFactory to use to construct extension messages.
|
||||||
// object_size: The size of a message object of this type, as measured
|
|
||||||
// by sizeof().
|
|
||||||
GeneratedMessageReflection(const Descriptor* descriptor,
|
GeneratedMessageReflection(const Descriptor* descriptor,
|
||||||
const Message* default_instance,
|
const ReflectionSchema& schema,
|
||||||
const int offsets[], int has_bits_offset,
|
|
||||||
int unknown_fields_offset, int extensions_offset,
|
|
||||||
const DescriptorPool* pool,
|
const DescriptorPool* pool,
|
||||||
MessageFactory* factory, int object_size,
|
MessageFactory* factory);
|
||||||
int arena_offset);
|
|
||||||
|
|
||||||
// Similar with the construction above. Call this construction if the
|
|
||||||
// message has oneof definition.
|
|
||||||
// Parameters:
|
|
||||||
// offsets: An array of ints giving the byte offsets.
|
|
||||||
// For each oneof field, the offset is relative to the
|
|
||||||
// default_oneof_instance. These can be computed at compile
|
|
||||||
// time using the
|
|
||||||
// PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro.
|
|
||||||
// For each none oneof field, the offset is related to
|
|
||||||
// the start of the message object. These can be computed
|
|
||||||
// at compile time using the
|
|
||||||
// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro.
|
|
||||||
// Besides offsets for all fields, this array also contains
|
|
||||||
// offsets for oneof unions. The offset of the i-th oneof
|
|
||||||
// union is offsets[descriptor->field_count() + i].
|
|
||||||
// default_oneof_instance: The default instance of the oneofs. It is a
|
|
||||||
// struct holding the default value of all oneof fields
|
|
||||||
// for this message. It is only used to obtain pointers
|
|
||||||
// to default instances of oneof fields, which Get
|
|
||||||
// methods will return if the field is not set.
|
|
||||||
// oneof_case_offset: Offset in the message of an array of uint32s of
|
|
||||||
// size descriptor->oneof_decl_count(). Each uint32
|
|
||||||
// indicates what field is set for each oneof.
|
|
||||||
// other parameters are the same with the construction above.
|
|
||||||
GeneratedMessageReflection(const Descriptor* descriptor,
|
|
||||||
const Message* default_instance,
|
|
||||||
const int offsets[], int has_bits_offset,
|
|
||||||
int unknown_fields_offset, int extensions_offset,
|
|
||||||
const void* default_oneof_instance,
|
|
||||||
int oneof_case_offset, const DescriptorPool* pool,
|
|
||||||
MessageFactory* factory, int object_size,
|
|
||||||
int arena_offset);
|
|
||||||
~GeneratedMessageReflection();
|
~GeneratedMessageReflection();
|
||||||
|
|
||||||
// Shorter-to-call helpers for the above two constructions that work if the
|
|
||||||
// pool and factory are the usual, namely, DescriptorPool::generated_pool()
|
|
||||||
// and MessageFactory::generated_factory().
|
|
||||||
|
|
||||||
static GeneratedMessageReflection* NewGeneratedMessageReflection(
|
|
||||||
const Descriptor* descriptor,
|
|
||||||
const Message* default_instance,
|
|
||||||
const int offsets[],
|
|
||||||
int has_bits_offset,
|
|
||||||
int unknown_fields_offset,
|
|
||||||
int extensions_offset,
|
|
||||||
const void* default_oneof_instance,
|
|
||||||
int oneof_case_offset,
|
|
||||||
int object_size,
|
|
||||||
int arena_offset,
|
|
||||||
int is_default_instance_offset = -1);
|
|
||||||
|
|
||||||
static GeneratedMessageReflection* NewGeneratedMessageReflection(
|
|
||||||
const Descriptor* descriptor,
|
|
||||||
const Message* default_instance,
|
|
||||||
const int offsets[],
|
|
||||||
int has_bits_offset,
|
|
||||||
int unknown_fields_offset,
|
|
||||||
int extensions_offset,
|
|
||||||
int object_size,
|
|
||||||
int arena_offset,
|
|
||||||
int is_default_instance_offset = -1);
|
|
||||||
|
|
||||||
// implements Reflection -------------------------------------------
|
// implements Reflection -------------------------------------------
|
||||||
|
|
||||||
const UnknownFieldSet& GetUnknownFields(const Message& message) const;
|
const UnknownFieldSet& GetUnknownFields(const Message& message) const;
|
||||||
UnknownFieldSet* MutableUnknownFields(Message* message) const;
|
UnknownFieldSet* MutableUnknownFields(Message* message) const;
|
||||||
|
|
||||||
int SpaceUsed(const Message& message) const;
|
size_t SpaceUsedLong(const Message& message) const;
|
||||||
|
|
||||||
bool HasField(const Message& message, const FieldDescriptor* field) const;
|
bool HasField(const Message& message, const FieldDescriptor* field) const;
|
||||||
int FieldSize(const Message& message, const FieldDescriptor* field) const;
|
int FieldSize(const Message& message, const FieldDescriptor* field) const;
|
||||||
@@ -423,37 +497,33 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
|||||||
const Descriptor* message_type) const;
|
const Descriptor* message_type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GeneratedMessage;
|
friend class google::protobuf::flat::MetadataBuilder;
|
||||||
|
|
||||||
// To parse directly into a proto2 generated class, the class GMR_Handlers
|
|
||||||
// needs access to member offsets and hasbits.
|
|
||||||
friend class upb::google_opensource::GMR_Handlers;
|
friend class upb::google_opensource::GMR_Handlers;
|
||||||
|
|
||||||
const Descriptor* descriptor_;
|
const Descriptor* const descriptor_;
|
||||||
const Message* default_instance_;
|
const ReflectionSchema schema_;
|
||||||
const void* default_oneof_instance_;
|
const DescriptorPool* const descriptor_pool_;
|
||||||
const int* offsets_;
|
MessageFactory* const message_factory_;
|
||||||
|
|
||||||
int has_bits_offset_;
|
// Last non weak field index. This is an optimization when most weak fields
|
||||||
int oneof_case_offset_;
|
// are at the end of the containing message. If a message proto doesn't
|
||||||
int unknown_fields_offset_;
|
// contain weak fields, then this field equals descriptor_->field_count().
|
||||||
int extensions_offset_;
|
int last_non_weak_field_index_;
|
||||||
int arena_offset_;
|
|
||||||
int object_size_;
|
|
||||||
|
|
||||||
const DescriptorPool* descriptor_pool_;
|
template <class T>
|
||||||
MessageFactory* message_factory_;
|
const T& GetRawNonOneof(const Message& message,
|
||||||
|
const FieldDescriptor* field) const;
|
||||||
|
template <class T>
|
||||||
|
T* MutableRawNonOneof(Message* message, const FieldDescriptor* field) const;
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline const Type& GetRaw(const Message& message,
|
const Type& GetRaw(const Message& message,
|
||||||
const FieldDescriptor* field) const;
|
const FieldDescriptor* field) const;
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline Type* MutableRaw(Message* message,
|
inline Type* MutableRaw(Message* message,
|
||||||
const FieldDescriptor* field) const;
|
const FieldDescriptor* field) const;
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline const Type& DefaultRaw(const FieldDescriptor* field) const;
|
inline const Type& DefaultRaw(const FieldDescriptor* field) const;
|
||||||
template <typename Type>
|
|
||||||
inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const;
|
|
||||||
|
|
||||||
inline const uint32* GetHasBits(const Message& message) const;
|
inline const uint32* GetHasBits(const Message& message) const;
|
||||||
inline uint32* MutableHasBits(Message* message) const;
|
inline uint32* MutableHasBits(Message* message) const;
|
||||||
@@ -466,12 +536,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
|||||||
inline const ExtensionSet& GetExtensionSet(const Message& message) const;
|
inline const ExtensionSet& GetExtensionSet(const Message& message) const;
|
||||||
inline ExtensionSet* MutableExtensionSet(Message* message) const;
|
inline ExtensionSet* MutableExtensionSet(Message* message) const;
|
||||||
inline Arena* GetArena(Message* message) const;
|
inline Arena* GetArena(Message* message) const;
|
||||||
inline const internal::InternalMetadataWithArena&
|
|
||||||
GetInternalMetadataWithArena(const Message& message) const;
|
|
||||||
inline internal::InternalMetadataWithArena*
|
|
||||||
MutableInternalMetadataWithArena(Message* message) const;
|
|
||||||
|
|
||||||
inline bool GetIsDefaultInstance(const Message& message) const;
|
inline const InternalMetadataWithArena& GetInternalMetadataWithArena(
|
||||||
|
const Message& message) const;
|
||||||
|
|
||||||
|
inline InternalMetadataWithArena*
|
||||||
|
MutableInternalMetadataWithArena(Message* message) const;
|
||||||
|
|
||||||
inline bool HasBit(const Message& message,
|
inline bool HasBit(const Message& message,
|
||||||
const FieldDescriptor* field) const;
|
const FieldDescriptor* field) const;
|
||||||
@@ -559,43 +629,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
|||||||
internal::MapFieldBase* MapData(
|
internal::MapFieldBase* MapData(
|
||||||
Message* message, const FieldDescriptor* field) const;
|
Message* message, const FieldDescriptor* field) const;
|
||||||
|
|
||||||
|
friend inline // inline so nobody can call this function.
|
||||||
|
void
|
||||||
|
RegisterAllTypesInternal(const Metadata* file_level_metadata, int size);
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the offset of the given field within the given aggregate type.
|
|
||||||
// This is equivalent to the ANSI C offsetof() macro. However, according
|
|
||||||
// to the C++ standard, offsetof() only works on POD types, and GCC
|
|
||||||
// enforces this requirement with a warning. In practice, this rule is
|
|
||||||
// unnecessarily strict; there is probably no compiler or platform on
|
|
||||||
// which the offsets of the direct fields of a class are non-constant.
|
|
||||||
// Fields inherited from superclasses *can* have non-constant offsets,
|
|
||||||
// but that's not what this macro will be used for.
|
|
||||||
#if defined(__clang__)
|
|
||||||
// For Clang we use __builtin_offsetof() and suppress the warning,
|
|
||||||
// to avoid Control Flow Integrity and UBSan vptr sanitizers from
|
|
||||||
// crashing while trying to validate the invalid reinterpet_casts.
|
|
||||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
|
|
||||||
_Pragma("clang diagnostic push") \
|
|
||||||
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
|
|
||||||
__builtin_offsetof(TYPE, FIELD) \
|
|
||||||
_Pragma("clang diagnostic pop")
|
|
||||||
#else
|
|
||||||
// Note that we calculate relative to the pointer value 16 here since if we
|
|
||||||
// just use zero, GCC complains about dereferencing a NULL pointer. We
|
|
||||||
// choose 16 rather than some other number just in case the compiler would
|
|
||||||
// be confused by an unaligned pointer.
|
|
||||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
|
|
||||||
static_cast<int>( \
|
|
||||||
reinterpret_cast<const char*>( \
|
|
||||||
&reinterpret_cast<const TYPE*>(16)->FIELD) - \
|
|
||||||
reinterpret_cast<const char*>(16))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \
|
|
||||||
static_cast<int>( \
|
|
||||||
reinterpret_cast<const char*>(&(ONEOF->FIELD)) \
|
|
||||||
- reinterpret_cast<const char*>(ONEOF))
|
|
||||||
|
|
||||||
// There are some places in proto2 where dynamic_cast would be useful as an
|
// There are some places in proto2 where dynamic_cast would be useful as an
|
||||||
// optimization. For example, take Message::MergeFrom(const Message& other).
|
// optimization. For example, take Message::MergeFrom(const Message& other).
|
||||||
// For a given generated message FooMessage, we generate these two methods:
|
// For a given generated message FooMessage, we generate these two methods:
|
||||||
@@ -622,6 +661,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
|
|||||||
template<typename To, typename From>
|
template<typename To, typename From>
|
||||||
inline To dynamic_cast_if_available(From from) {
|
inline To dynamic_cast_if_available(From from) {
|
||||||
#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
|
#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
|
||||||
|
// Avoid the compiler warning about unused variables.
|
||||||
|
(void)from;
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
return dynamic_cast<To>(from);
|
return dynamic_cast<To>(from);
|
||||||
@@ -664,6 +705,22 @@ T* DynamicCastToGenerated(Message* from) {
|
|||||||
return const_cast<T*>(DynamicCastToGenerated<const T>(message_const));
|
return const_cast<T*>(DynamicCastToGenerated<const T>(message_const));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT void AssignDescriptors(
|
||||||
|
const string& filename, const MigrationSchema* schemas,
|
||||||
|
const Message* const* default_instances_, const uint32* offsets,
|
||||||
|
MessageFactory* factory,
|
||||||
|
// update the following descriptor arrays.
|
||||||
|
Metadata* file_level_metadata,
|
||||||
|
const EnumDescriptor** file_level_enum_descriptors,
|
||||||
|
const ServiceDescriptor** file_level_service_descriptors);
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT void RegisterAllTypes(const Metadata* file_level_metadata, int size);
|
||||||
|
|
||||||
|
// These cannot be in lite so we put them in the reflection.
|
||||||
|
LIBPROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8* base, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/type_traits.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/generated_message_table_driven_lite.h>
|
||||||
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||||
|
#include <google/protobuf/metadata.h>
|
||||||
|
#include <google/protobuf/repeated_field.h>
|
||||||
|
#include <google/protobuf/wire_format.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64 arena_offset) {
|
||||||
|
return Raw<InternalMetadataWithArena>(msg, arena_offset)
|
||||||
|
->mutable_unknown_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UnknownFieldHandler {
|
||||||
|
static bool Skip(MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input,
|
||||||
|
int tag) {
|
||||||
|
GOOGLE_DCHECK(table.unknown_field_set);
|
||||||
|
|
||||||
|
return WireFormat::SkipField(input, tag,
|
||||||
|
MutableUnknownFields(msg, table.arena_offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Varint(MessageLite* msg, const ParseTable& table,
|
||||||
|
int tag, int value) {
|
||||||
|
GOOGLE_DCHECK(table.unknown_field_set);
|
||||||
|
|
||||||
|
MutableUnknownFields(msg, table.arena_offset)->AddVarint(
|
||||||
|
WireFormatLite::GetTagFieldNumber(tag), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ParseExtension(
|
||||||
|
MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input, int tag) {
|
||||||
|
ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset);
|
||||||
|
if (extensions == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Message* prototype = down_cast<const Message*>(
|
||||||
|
table.default_instance());
|
||||||
|
|
||||||
|
GOOGLE_DCHECK(prototype != NULL);
|
||||||
|
GOOGLE_DCHECK(table.unknown_field_set);
|
||||||
|
UnknownFieldSet* unknown_fields =
|
||||||
|
MutableUnknownFields(msg, table.arena_offset);
|
||||||
|
|
||||||
|
return extensions->ParseField(tag, input, prototype, unknown_fields);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool MergePartialFromCodedStream(
|
||||||
|
MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) {
|
||||||
|
return MergePartialFromCodedStreamImpl<UnknownFieldHandler,
|
||||||
|
InternalMetadataWithArena>(msg, table,
|
||||||
|
input);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
|
||||||
|
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
|
||||||
|
|
||||||
|
#include <google/protobuf/map.h>
|
||||||
|
#include <google/protobuf/map_entry_lite.h>
|
||||||
|
#include <google/protobuf/map_field_lite.h>
|
||||||
|
#include <google/protobuf/message_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
#define PROTOBUF_CONSTEXPR constexpr
|
||||||
|
|
||||||
|
// We require C++11 and Clang to use constexpr for variables, as GCC 4.8
|
||||||
|
// requires constexpr to be consistent between declarations of variables
|
||||||
|
// unnecessarily (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541).
|
||||||
|
// VS 2017 Update 3 also supports this usage of constexpr.
|
||||||
|
#if defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1911)
|
||||||
|
#define PROTOBUF_CONSTEXPR_VAR constexpr
|
||||||
|
#else // !__clang__
|
||||||
|
#define PROTOBUF_CONSTEXPR_VAR
|
||||||
|
#endif // !_clang
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define PROTOBUF_CONSTEXPR
|
||||||
|
#define PROTOBUF_CONSTEXPR_VAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
// Processing-type masks.
|
||||||
|
static PROTOBUF_CONSTEXPR const unsigned char kOneofMask = 0x40;
|
||||||
|
static PROTOBUF_CONSTEXPR const unsigned char kRepeatedMask = 0x20;
|
||||||
|
// Mask for the raw type: either a WireFormatLite::FieldType or one of the
|
||||||
|
// ProcessingTypes below, without the oneof or repeated flag.
|
||||||
|
static PROTOBUF_CONSTEXPR const unsigned char kTypeMask = 0x1f;
|
||||||
|
|
||||||
|
// Wire type masks.
|
||||||
|
static PROTOBUF_CONSTEXPR const unsigned char kNotPackedMask = 0x10;
|
||||||
|
static PROTOBUF_CONSTEXPR const unsigned char kInvalidMask = 0x20;
|
||||||
|
|
||||||
|
enum ProcessingTypes {
|
||||||
|
TYPE_STRING_CORD = 19,
|
||||||
|
TYPE_STRING_STRING_PIECE = 20,
|
||||||
|
TYPE_BYTES_CORD = 21,
|
||||||
|
TYPE_BYTES_STRING_PIECE = 22,
|
||||||
|
TYPE_MAP = 23,
|
||||||
|
};
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
static_assert(TYPE_MAP < kRepeatedMask, "Invalid enum");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO(ckennelly): Add a static assertion to ensure that these masks do not
|
||||||
|
// conflict with wiretypes.
|
||||||
|
|
||||||
|
// ParseTableField is kept small to help simplify instructions for computing
|
||||||
|
// offsets, as we will always need this information to parse a field.
|
||||||
|
// Additional data, needed for some types, is stored in
|
||||||
|
// AuxillaryParseTableField.
|
||||||
|
struct ParseTableField {
|
||||||
|
uint32 offset;
|
||||||
|
// The presence_index ordinarily represents a has_bit index, but for fields
|
||||||
|
// inside a oneof it represents the index in _oneof_case_.
|
||||||
|
uint32 presence_index;
|
||||||
|
unsigned char normal_wiretype;
|
||||||
|
unsigned char packed_wiretype;
|
||||||
|
|
||||||
|
// processing_type is given by:
|
||||||
|
// (FieldDescriptor->type() << 1) | FieldDescriptor->is_packed()
|
||||||
|
unsigned char processing_type;
|
||||||
|
|
||||||
|
unsigned char tag_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ParseTable;
|
||||||
|
|
||||||
|
union AuxillaryParseTableField {
|
||||||
|
typedef bool (*EnumValidator)(int);
|
||||||
|
|
||||||
|
// Enums
|
||||||
|
struct enum_aux {
|
||||||
|
EnumValidator validator;
|
||||||
|
};
|
||||||
|
enum_aux enums;
|
||||||
|
// Group, messages
|
||||||
|
struct message_aux {
|
||||||
|
// ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents
|
||||||
|
// the tables from being constructed as a constexpr. We use void to avoid
|
||||||
|
// the cast.
|
||||||
|
const void* default_message_void;
|
||||||
|
const MessageLite* default_message() const {
|
||||||
|
return static_cast<const MessageLite*>(default_message_void);
|
||||||
|
}
|
||||||
|
const ParseTable* parse_table;
|
||||||
|
};
|
||||||
|
message_aux messages;
|
||||||
|
// Strings
|
||||||
|
struct string_aux {
|
||||||
|
const void* default_ptr;
|
||||||
|
const char* field_name;
|
||||||
|
};
|
||||||
|
string_aux strings;
|
||||||
|
|
||||||
|
struct map_aux {
|
||||||
|
bool (*parse_map)(io::CodedInputStream*, void*);
|
||||||
|
};
|
||||||
|
map_aux maps;
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
AuxillaryParseTableField() = default;
|
||||||
|
#else
|
||||||
|
AuxillaryParseTableField() { }
|
||||||
|
#endif
|
||||||
|
PROTOBUF_CONSTEXPR AuxillaryParseTableField(
|
||||||
|
AuxillaryParseTableField::enum_aux e) : enums(e) {}
|
||||||
|
PROTOBUF_CONSTEXPR AuxillaryParseTableField(
|
||||||
|
AuxillaryParseTableField::message_aux m) : messages(m) {}
|
||||||
|
PROTOBUF_CONSTEXPR AuxillaryParseTableField(
|
||||||
|
AuxillaryParseTableField::string_aux s) : strings(s) {}
|
||||||
|
PROTOBUF_CONSTEXPR AuxillaryParseTableField(
|
||||||
|
AuxillaryParseTableField::map_aux m)
|
||||||
|
: maps(m) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ParseTable {
|
||||||
|
const ParseTableField* fields;
|
||||||
|
const AuxillaryParseTableField* aux;
|
||||||
|
int max_field_number;
|
||||||
|
// TODO(ckennelly): Do something with this padding.
|
||||||
|
|
||||||
|
// TODO(ckennelly): Vet these for sign extension.
|
||||||
|
int64 has_bits_offset;
|
||||||
|
int64 oneof_case_offset;
|
||||||
|
int64 extension_offset;
|
||||||
|
int64 arena_offset;
|
||||||
|
|
||||||
|
// ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents
|
||||||
|
// the tables from being constructed as a constexpr. We use void to avoid
|
||||||
|
// the cast.
|
||||||
|
const void* default_instance_void;
|
||||||
|
const MessageLite* default_instance() const {
|
||||||
|
return static_cast<const MessageLite*>(default_instance_void);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool unknown_field_set;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO(jhen): Remove the __NVCC__ check when we get a version of nvcc that
|
||||||
|
// supports these checks.
|
||||||
|
#if LANG_CXX11 && !defined(__NVCC__)
|
||||||
|
static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
|
||||||
|
// The tables must be composed of POD components to ensure link-time
|
||||||
|
// initialization.
|
||||||
|
static_assert(std::is_pod<ParseTableField>::value, "");
|
||||||
|
static_assert(std::is_pod<AuxillaryParseTableField>::value, "");
|
||||||
|
static_assert(std::is_pod<AuxillaryParseTableField::enum_aux>::value, "");
|
||||||
|
static_assert(std::is_pod<AuxillaryParseTableField::message_aux>::value, "");
|
||||||
|
static_assert(std::is_pod<AuxillaryParseTableField::string_aux>::value, "");
|
||||||
|
static_assert(std::is_pod<ParseTable>::value, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO(ckennelly): Consolidate these implementations into a single one, using
|
||||||
|
// dynamic dispatch to the appropriate unknown field handler.
|
||||||
|
bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input);
|
||||||
|
bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input);
|
||||||
|
|
||||||
|
template <typename Entry>
|
||||||
|
bool ParseMap(io::CodedInputStream* input, void* map_field) {
|
||||||
|
typedef typename MapEntryToMapField<Entry>::MapFieldType MapFieldType;
|
||||||
|
typedef google::protobuf::Map<typename Entry::EntryKeyType,
|
||||||
|
typename Entry::EntryValueType>
|
||||||
|
MapType;
|
||||||
|
typedef typename Entry::template Parser<MapFieldType, MapType> ParserType;
|
||||||
|
|
||||||
|
ParserType parser(static_cast<MapFieldType*>(map_field));
|
||||||
|
return ::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(input,
|
||||||
|
&parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include <google/protobuf/generated_message_table_driven_lite.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/type_traits.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||||
|
#include <google/protobuf/metadata_lite.h>
|
||||||
|
#include <google/protobuf/repeated_field.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
string* MutableUnknownFields(MessageLite* msg, int64 arena_offset) {
|
||||||
|
return Raw<InternalMetadataWithArenaLite>(msg, arena_offset)
|
||||||
|
->mutable_unknown_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UnknownFieldHandlerLite {
|
||||||
|
static bool Skip(MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input,
|
||||||
|
int tag) {
|
||||||
|
GOOGLE_DCHECK(!table.unknown_field_set);
|
||||||
|
::google::protobuf::io::StringOutputStream unknown_fields_string(
|
||||||
|
MutableUnknownFields(msg, table.arena_offset));
|
||||||
|
::google::protobuf::io::CodedOutputStream unknown_fields_stream(
|
||||||
|
&unknown_fields_string, false);
|
||||||
|
|
||||||
|
return ::google::protobuf::internal::WireFormatLite::SkipField(
|
||||||
|
input, tag, &unknown_fields_stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Varint(MessageLite* msg, const ParseTable& table,
|
||||||
|
int tag, int value) {
|
||||||
|
GOOGLE_DCHECK(!table.unknown_field_set);
|
||||||
|
|
||||||
|
::google::protobuf::io::StringOutputStream unknown_fields_string(
|
||||||
|
MutableUnknownFields(msg, table.arena_offset));
|
||||||
|
::google::protobuf::io::CodedOutputStream unknown_fields_stream(
|
||||||
|
&unknown_fields_string, false);
|
||||||
|
unknown_fields_stream.WriteVarint32(tag);
|
||||||
|
unknown_fields_stream.WriteVarint32(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ParseExtension(
|
||||||
|
MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input, int tag) {
|
||||||
|
ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset);
|
||||||
|
if (extensions == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MessageLite* prototype = table.default_instance();
|
||||||
|
|
||||||
|
GOOGLE_DCHECK(!table.unknown_field_set);
|
||||||
|
::google::protobuf::io::StringOutputStream unknown_fields_string(
|
||||||
|
MutableUnknownFields(msg, table.arena_offset));
|
||||||
|
::google::protobuf::io::CodedOutputStream unknown_fields_stream(
|
||||||
|
&unknown_fields_string, false);
|
||||||
|
return extensions->ParseField(
|
||||||
|
tag, input, prototype, &unknown_fields_stream);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool MergePartialFromCodedStreamLite(
|
||||||
|
MessageLite* msg, const ParseTable& table, io::CodedInputStream* input) {
|
||||||
|
return MergePartialFromCodedStreamImpl<UnknownFieldHandlerLite,
|
||||||
|
InternalMetadataWithArenaLite>(
|
||||||
|
msg, table, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
@@ -0,0 +1,823 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
|
||||||
|
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
|
||||||
|
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/type_traits.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||||
|
#include <google/protobuf/extension_set.h>
|
||||||
|
#include <google/protobuf/metadata_lite.h>
|
||||||
|
#include <google/protobuf/repeated_field.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
|
enum StringType {
|
||||||
|
StringType_STRING = 0,
|
||||||
|
StringType_CORD = 1,
|
||||||
|
StringType_STRING_PIECE = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
// Logically a superset of StringType, consisting of all field types that
|
||||||
|
// require special initialization.
|
||||||
|
enum ProcessingType {
|
||||||
|
ProcessingType_STRING = 0,
|
||||||
|
ProcessingType_CORD = 1,
|
||||||
|
ProcessingType_STRING_PIECE = 2,
|
||||||
|
ProcessingType_MESSAGE = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Cardinality {
|
||||||
|
Cardinality_SINGULAR = 0,
|
||||||
|
Cardinality_REPEATED = 1,
|
||||||
|
Cardinality_ONEOF = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline Type* Raw(MessageLite* msg, int64 offset) {
|
||||||
|
return reinterpret_cast<Type*>(reinterpret_cast<uint8*>(msg) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline const Type* Raw(const MessageLite* msg, int64 offset) {
|
||||||
|
return reinterpret_cast<const Type*>(reinterpret_cast<const uint8*>(msg) +
|
||||||
|
offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename InternalMetadata>
|
||||||
|
inline Arena* GetArena(MessageLite* msg, int64 arena_offset) {
|
||||||
|
if (GOOGLE_PREDICT_FALSE(arena_offset == -1)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Raw<InternalMetadata>(msg, arena_offset)->arena();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ExtensionSet* GetExtensionSet(MessageLite* msg, int64 extension_offset) {
|
||||||
|
if (extension_offset == -1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Raw<ExtensionSet>(msg, extension_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline Type* AddField(MessageLite* msg, int64 offset) {
|
||||||
|
#if LANG_CXX11
|
||||||
|
static_assert(has_trivial_copy<Type>::value,
|
||||||
|
"Do not assign");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
google::protobuf::RepeatedField<Type>* repeated =
|
||||||
|
Raw<google::protobuf::RepeatedField<Type> >(msg, offset);
|
||||||
|
return repeated->Add();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline string* AddField<string>(MessageLite* msg, int64 offset) {
|
||||||
|
google::protobuf::RepeatedPtrField<string>* repeated =
|
||||||
|
Raw<google::protobuf::RepeatedPtrField<string> >(msg, offset);
|
||||||
|
return repeated->Add();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline void AddField(MessageLite* msg, int64 offset, Type value) {
|
||||||
|
#if LANG_CXX11
|
||||||
|
static_assert(has_trivial_copy<Type>::value,
|
||||||
|
"Do not assign");
|
||||||
|
#endif
|
||||||
|
*AddField<Type>(msg, offset) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetBit(uint32* has_bits, uint32 has_bit_index) {
|
||||||
|
GOOGLE_DCHECK(has_bits != NULL);
|
||||||
|
|
||||||
|
uint32 mask = static_cast<uint32>(1u) << (has_bit_index % 32);
|
||||||
|
has_bits[has_bit_index / 32u] |= mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline Type* MutableField(MessageLite* msg, uint32* has_bits,
|
||||||
|
uint32 has_bit_index, int64 offset) {
|
||||||
|
SetBit(has_bits, has_bit_index);
|
||||||
|
return Raw<Type>(msg, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index,
|
||||||
|
int64 offset, Type value) {
|
||||||
|
#if LANG_CXX11
|
||||||
|
static_assert(has_trivial_copy<Type>::value,
|
||||||
|
"Do not assign");
|
||||||
|
#endif
|
||||||
|
*MutableField<Type>(msg, has_bits, has_bit_index, offset) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
inline void SetOneofField(MessageLite* msg, uint32* oneof_case,
|
||||||
|
uint32 oneof_case_index, int64 offset,
|
||||||
|
int field_number, Type value) {
|
||||||
|
oneof_case[oneof_case_index] = field_number;
|
||||||
|
*Raw<Type>(msg, offset) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clears a oneof field. The field argument should correspond to the particular
|
||||||
|
// field that is currently set in the oneof.
|
||||||
|
inline void ClearOneofField(const ParseTableField& field, Arena* arena,
|
||||||
|
MessageLite* msg) {
|
||||||
|
switch (field.processing_type & kTypeMask) {
|
||||||
|
case WireFormatLite::TYPE_MESSAGE:
|
||||||
|
if (arena == NULL) {
|
||||||
|
delete *Raw<MessageLite*>(msg, field.offset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WireFormatLite::TYPE_STRING:
|
||||||
|
case WireFormatLite::TYPE_BYTES:
|
||||||
|
Raw<ArenaStringPtr>(msg, field.offset)
|
||||||
|
->Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// No cleanup needed.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clears and reinitializes a oneof field as necessary, in preparation for
|
||||||
|
// parsing a new value with type field_type and field number field_number.
|
||||||
|
//
|
||||||
|
// Note: the oneof_case argument should point directly to the _oneof_case_
|
||||||
|
// element corresponding to this particular oneof, not to the beginning of the
|
||||||
|
// _oneof_case_ array.
|
||||||
|
template <ProcessingType field_type>
|
||||||
|
inline void ResetOneofField(const ParseTable& table, int field_number,
|
||||||
|
Arena* arena, MessageLite* msg, uint32* oneof_case,
|
||||||
|
int64 offset, const void* default_ptr) {
|
||||||
|
if (*oneof_case == field_number) {
|
||||||
|
// The oneof is already set to the right type, so there is no need to clear
|
||||||
|
// it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*oneof_case != 0) {
|
||||||
|
ClearOneofField(table.fields[*oneof_case], arena, msg);
|
||||||
|
}
|
||||||
|
*oneof_case = field_number;
|
||||||
|
|
||||||
|
switch (field_type) {
|
||||||
|
case ProcessingType_STRING:
|
||||||
|
Raw<ArenaStringPtr>(msg, offset)
|
||||||
|
->UnsafeSetDefault(static_cast<const string*>(default_ptr));
|
||||||
|
break;
|
||||||
|
case ProcessingType_MESSAGE:
|
||||||
|
MessageLite** submessage = Raw<MessageLite*>(msg, offset);
|
||||||
|
const MessageLite* prototype =
|
||||||
|
table.aux[field_number].messages.default_message();
|
||||||
|
*submessage = prototype->New(arena);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <Cardinality cardinality, bool validate, StringType ctype>
|
||||||
|
static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg,
|
||||||
|
Arena* arena, uint32* has_bits,
|
||||||
|
uint32 has_bit_index, int64 offset,
|
||||||
|
const void* default_ptr,
|
||||||
|
const char* field_name) {
|
||||||
|
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
const char* sdata;
|
||||||
|
size_t size;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
string* value;
|
||||||
|
switch (cardinality) {
|
||||||
|
case Cardinality_SINGULAR:
|
||||||
|
// TODO(ckennelly): Is this optimal?
|
||||||
|
value =
|
||||||
|
MutableField<ArenaStringPtr>(msg, has_bits, has_bit_index, offset)
|
||||||
|
->Mutable(static_cast<const string*>(default_ptr), arena);
|
||||||
|
break;
|
||||||
|
case Cardinality_REPEATED:
|
||||||
|
value = AddField<string>(msg, offset);
|
||||||
|
break;
|
||||||
|
case Cardinality_ONEOF:
|
||||||
|
value = Raw<ArenaStringPtr>(msg, offset)
|
||||||
|
->Mutable(static_cast<const string*>(default_ptr), arena);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
sdata = value->data();
|
||||||
|
size = value->size();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
if (validate) {
|
||||||
|
WireFormatLite::VerifyUtf8String(sdata, size, WireFormatLite::PARSE,
|
||||||
|
field_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename UnknownFieldHandler, typename InternalMetadata,
|
||||||
|
Cardinality cardinality>
|
||||||
|
inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input,
|
||||||
|
MessageLite* msg, uint32* presence,
|
||||||
|
uint32 presence_index, int64 offset, uint32 tag,
|
||||||
|
int field_number) {
|
||||||
|
int value;
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
|
||||||
|
input, &value)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuxillaryParseTableField::EnumValidator validator =
|
||||||
|
table.aux[field_number].enums.validator;
|
||||||
|
if (validator(value)) {
|
||||||
|
switch (cardinality) {
|
||||||
|
case Cardinality_SINGULAR:
|
||||||
|
SetField(msg, presence, presence_index, offset, value);
|
||||||
|
break;
|
||||||
|
case Cardinality_REPEATED:
|
||||||
|
AddField(msg, offset, value);
|
||||||
|
break;
|
||||||
|
case Cardinality_ONEOF:
|
||||||
|
ClearOneofField(table.fields[presence[presence_index]],
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset),
|
||||||
|
msg);
|
||||||
|
SetOneofField(msg, presence, presence_index, offset, field_number,
|
||||||
|
value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UnknownFieldHandler::Varint(msg, table, tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RepeatedMessageTypeHandler allows us to operate on RepeatedPtrField fields
|
||||||
|
// without instantiating the specific template.
|
||||||
|
class RepeatedMessageTypeHandler {
|
||||||
|
public:
|
||||||
|
typedef MessageLite Type;
|
||||||
|
static Arena* GetArena(Type* t) { return t->GetArena(); }
|
||||||
|
static void* GetMaybeArenaPointer(Type* t) {
|
||||||
|
return t->GetMaybeArenaPointer();
|
||||||
|
}
|
||||||
|
static inline Type* NewFromPrototype(const Type* prototype,
|
||||||
|
Arena* arena = NULL) {
|
||||||
|
return prototype->New(arena);
|
||||||
|
}
|
||||||
|
static void Delete(Type* t, Arena* arena = NULL) {
|
||||||
|
if (arena == NULL) {
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool ReadGroup(int field_number, io::CodedInputStream* input,
|
||||||
|
MessageLite* value) {
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!input->IncrementRecursionDepth())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!value->MergePartialFromCodedStream(input))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
input->DecrementRecursionDepth();
|
||||||
|
// Make sure the last thing read was an end tag for this group.
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!input->LastTagWas(WireFormatLite::MakeTag(
|
||||||
|
field_number, WireFormatLite::WIRETYPE_END_GROUP)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ReadMessage(io::CodedInputStream* input, MessageLite* value) {
|
||||||
|
int length;
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!input->ReadVarintSizeAsInt(&length))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<io::CodedInputStream::Limit, int> p =
|
||||||
|
input->IncrementRecursionDepthAndPushLimit(length);
|
||||||
|
if (GOOGLE_PREDICT_FALSE(p.second < 0 ||
|
||||||
|
!value->MergePartialFromCodedStream(input))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that parsing stopped when the limit was hit, not at an endgroup
|
||||||
|
// tag.
|
||||||
|
return input->DecrementRecursionDepthAndPopLimit(p.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MergePartialFromCodedStreamHelper {
|
||||||
|
public:
|
||||||
|
static MessageLite* Add(RepeatedPtrFieldBase* field,
|
||||||
|
const MessageLite* prototype) {
|
||||||
|
return field->Add<RepeatedMessageTypeHandler>(
|
||||||
|
const_cast<MessageLite*>(prototype));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename UnknownFieldHandler, typename InternalMetadata>
|
||||||
|
bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table,
|
||||||
|
io::CodedInputStream* input) {
|
||||||
|
// We require that has_bits are present, as to avoid having to check for them
|
||||||
|
// for every field.
|
||||||
|
//
|
||||||
|
// TODO(ckennelly): Make this a compile-time parameter with templates.
|
||||||
|
GOOGLE_DCHECK_GE(table.has_bits_offset, 0);
|
||||||
|
uint32* has_bits = Raw<uint32>(msg, table.has_bits_offset);
|
||||||
|
GOOGLE_DCHECK(has_bits != NULL);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
uint32 tag = input->ReadTag();
|
||||||
|
|
||||||
|
const WireFormatLite::WireType wire_type =
|
||||||
|
WireFormatLite::GetTagWireType(tag);
|
||||||
|
const int field_number = WireFormatLite::GetTagFieldNumber(tag);
|
||||||
|
|
||||||
|
if (field_number > table.max_field_number) {
|
||||||
|
// check for possible extensions
|
||||||
|
if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) {
|
||||||
|
// successfully parsed
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!UnknownFieldHandler::Skip(msg, table, input, tag))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We implicitly verify that data points to a valid field as we check the
|
||||||
|
// wire types. Entries in table.fields[i] that do not correspond to valid
|
||||||
|
// field numbers have their normal_wiretype and packed_wiretype fields set
|
||||||
|
// with the kInvalidMask value. As wire_type cannot take on that value, we
|
||||||
|
// will never match.
|
||||||
|
const ParseTableField* data = table.fields + field_number;
|
||||||
|
|
||||||
|
// TODO(ckennelly): Avoid sign extension
|
||||||
|
const int64 presence_index = data->presence_index;
|
||||||
|
const int64 offset = data->offset;
|
||||||
|
const unsigned char processing_type = data->processing_type;
|
||||||
|
|
||||||
|
if (data->normal_wiretype == static_cast<unsigned char>(wire_type)) {
|
||||||
|
// TODO(ckennelly): Use a computed goto on GCC/LLVM or otherwise eliminate
|
||||||
|
// the bounds check on processing_type.
|
||||||
|
|
||||||
|
switch (processing_type) {
|
||||||
|
#define HANDLE_TYPE(TYPE, CPPTYPE) \
|
||||||
|
case (WireFormatLite::TYPE_##TYPE): { \
|
||||||
|
CPPTYPE value; \
|
||||||
|
if (GOOGLE_PREDICT_FALSE( \
|
||||||
|
(!WireFormatLite::ReadPrimitive< \
|
||||||
|
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
SetField(msg, has_bits, presence_index, offset, value); \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \
|
||||||
|
google::protobuf::RepeatedField<CPPTYPE>* values = \
|
||||||
|
Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \
|
||||||
|
if (GOOGLE_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \
|
||||||
|
CPPTYPE, WireFormatLite::TYPE_##TYPE>( \
|
||||||
|
data->tag_size, tag, input, values)))) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \
|
||||||
|
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset); \
|
||||||
|
CPPTYPE value; \
|
||||||
|
if (GOOGLE_PREDICT_FALSE( \
|
||||||
|
(!WireFormatLite::ReadPrimitive< \
|
||||||
|
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
ClearOneofField(table.fields[oneof_case[presence_index]], \
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset), msg); \
|
||||||
|
SetOneofField(msg, oneof_case, presence_index, offset, field_number, \
|
||||||
|
value); \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE_TYPE(INT32, int32)
|
||||||
|
HANDLE_TYPE(INT64, int64)
|
||||||
|
HANDLE_TYPE(SINT32, int32)
|
||||||
|
HANDLE_TYPE(SINT64, int64)
|
||||||
|
HANDLE_TYPE(UINT32, uint32)
|
||||||
|
HANDLE_TYPE(UINT64, uint64)
|
||||||
|
|
||||||
|
HANDLE_TYPE(FIXED32, uint32)
|
||||||
|
HANDLE_TYPE(FIXED64, uint64)
|
||||||
|
HANDLE_TYPE(SFIXED32, int32)
|
||||||
|
HANDLE_TYPE(SFIXED64, int64)
|
||||||
|
|
||||||
|
HANDLE_TYPE(FLOAT, float)
|
||||||
|
HANDLE_TYPE(DOUBLE, double)
|
||||||
|
|
||||||
|
HANDLE_TYPE(BOOL, bool)
|
||||||
|
#undef HANDLE_TYPE
|
||||||
|
case WireFormatLite::TYPE_BYTES:
|
||||||
|
#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
case WireFormatLite::TYPE_STRING:
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const void* default_ptr = table.aux[field_number].strings.default_ptr;
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE((
|
||||||
|
!HandleString<Cardinality_SINGULAR, false, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, NULL)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_BYTES | kOneofMask:
|
||||||
|
#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
case WireFormatLite::TYPE_STRING | kOneofMask:
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
|
||||||
|
const void* default_ptr = table.aux[field_number].strings.default_ptr;
|
||||||
|
|
||||||
|
ResetOneofField<ProcessingType_STRING>(
|
||||||
|
table, field_number, arena, msg, oneof_case + presence_index,
|
||||||
|
offset, default_ptr);
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!HandleString<Cardinality_ONEOF, false, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, NULL)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (WireFormatLite::TYPE_BYTES) | kRepeatedMask:
|
||||||
|
#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
case (WireFormatLite::TYPE_STRING) | kRepeatedMask:
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const void* default_ptr =
|
||||||
|
table.aux[field_number].strings.default_ptr;
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE((
|
||||||
|
!HandleString<Cardinality_REPEATED, false, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, NULL)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
|
||||||
|
case (WireFormatLite::TYPE_STRING): {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const void* default_ptr = table.aux[field_number].strings.default_ptr;
|
||||||
|
const char* field_name = table.aux[field_number].strings.field_name;
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!HandleString<Cardinality_SINGULAR, true, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, field_name)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (WireFormatLite::TYPE_STRING) | kRepeatedMask: {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const void* default_ptr = table.aux[field_number].strings.default_ptr;
|
||||||
|
const char* field_name = table.aux[field_number].strings.field_name;
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!HandleString<Cardinality_REPEATED, true, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, field_name)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (WireFormatLite::TYPE_STRING) | kOneofMask: {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
|
||||||
|
const void* default_ptr = table.aux[field_number].strings.default_ptr;
|
||||||
|
const char* field_name = table.aux[field_number].strings.field_name;
|
||||||
|
|
||||||
|
ResetOneofField<ProcessingType_STRING>(
|
||||||
|
table, field_number, arena, msg, oneof_case + presence_index,
|
||||||
|
offset, default_ptr);
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!HandleString<Cardinality_ONEOF, true, StringType_STRING>(
|
||||||
|
input, msg, arena, has_bits, presence_index, offset,
|
||||||
|
default_ptr, field_name)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
case WireFormatLite::TYPE_ENUM: {
|
||||||
|
if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
|
||||||
|
Cardinality_SINGULAR>(
|
||||||
|
table, input, msg, has_bits, presence_index, offset, tag,
|
||||||
|
field_number)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_ENUM | kRepeatedMask: {
|
||||||
|
if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
|
||||||
|
Cardinality_REPEATED>(
|
||||||
|
table, input, msg, has_bits, presence_index, offset, tag,
|
||||||
|
field_number)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_ENUM | kOneofMask: {
|
||||||
|
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
|
||||||
|
if (GOOGLE_PREDICT_FALSE((!HandleEnum<UnknownFieldHandler, InternalMetadata,
|
||||||
|
Cardinality_ONEOF>(
|
||||||
|
table, input, msg, oneof_case, presence_index, offset, tag,
|
||||||
|
field_number)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_GROUP: {
|
||||||
|
MessageLite** submsg_holder =
|
||||||
|
MutableField<MessageLite*>(msg, has_bits, presence_index, offset);
|
||||||
|
MessageLite* submsg = *submsg_holder;
|
||||||
|
|
||||||
|
if (submsg == NULL) {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const MessageLite* prototype =
|
||||||
|
table.aux[field_number].messages.default_message();
|
||||||
|
submsg = prototype->New(arena);
|
||||||
|
*submsg_holder = submsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadGroup(
|
||||||
|
field_number, input, submsg))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_GROUP | kRepeatedMask: {
|
||||||
|
RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset);
|
||||||
|
const MessageLite* prototype =
|
||||||
|
table.aux[field_number].messages.default_message();
|
||||||
|
GOOGLE_DCHECK(prototype != NULL);
|
||||||
|
|
||||||
|
MessageLite* submsg =
|
||||||
|
MergePartialFromCodedStreamHelper::Add(field, prototype);
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadGroup(
|
||||||
|
field_number, input, submsg))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_MESSAGE: {
|
||||||
|
MessageLite** submsg_holder =
|
||||||
|
MutableField<MessageLite*>(msg, has_bits, presence_index, offset);
|
||||||
|
MessageLite* submsg = *submsg_holder;
|
||||||
|
|
||||||
|
if (submsg == NULL) {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
const MessageLite* prototype =
|
||||||
|
table.aux[field_number].messages.default_message();
|
||||||
|
submsg = prototype->New(arena);
|
||||||
|
*submsg_holder = submsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// TODO(ckennelly): Adapt ReadMessageNoVirtualNoRecursionDepth and
|
||||||
|
// manage input->IncrementRecursionDepth() here.
|
||||||
|
case WireFormatLite::TYPE_MESSAGE | kRepeatedMask: {
|
||||||
|
RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset);
|
||||||
|
const MessageLite* prototype =
|
||||||
|
table.aux[field_number].messages.default_message();
|
||||||
|
GOOGLE_DCHECK(prototype != NULL);
|
||||||
|
|
||||||
|
MessageLite* submsg =
|
||||||
|
MergePartialFromCodedStreamHelper::Add(field, prototype);
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_MESSAGE | kOneofMask: {
|
||||||
|
Arena* const arena =
|
||||||
|
GetArena<InternalMetadata>(msg, table.arena_offset);
|
||||||
|
uint32* oneof_case = Raw<uint32>(msg, table.oneof_case_offset);
|
||||||
|
MessageLite** submsg_holder = Raw<MessageLite*>(msg, offset);
|
||||||
|
ResetOneofField<ProcessingType_MESSAGE>(
|
||||||
|
table, field_number, arena, msg, oneof_case + presence_index,
|
||||||
|
offset, NULL);
|
||||||
|
MessageLite* submsg = *submsg_holder;
|
||||||
|
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!WireFormatLite::ReadMessage(input, submsg))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TYPE_MAP: {
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)(
|
||||||
|
input, Raw<void>(msg, offset)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0: {
|
||||||
|
// Done.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (data->packed_wiretype == static_cast<unsigned char>(wire_type)) {
|
||||||
|
// Non-packable fields have their packed_wiretype masked with
|
||||||
|
// kNotPackedMask, which is impossible to match here.
|
||||||
|
GOOGLE_DCHECK(processing_type & kRepeatedMask);
|
||||||
|
GOOGLE_DCHECK_NE(processing_type, kRepeatedMask);
|
||||||
|
GOOGLE_DCHECK_EQ(0, processing_type & kOneofMask);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO(ckennelly): Use a computed goto on GCC/LLVM.
|
||||||
|
//
|
||||||
|
// Mask out kRepeatedMask bit, allowing the jump table to be smaller.
|
||||||
|
switch (static_cast<WireFormatLite::FieldType>(
|
||||||
|
processing_type ^ kRepeatedMask)) {
|
||||||
|
#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \
|
||||||
|
case WireFormatLite::TYPE_##TYPE: { \
|
||||||
|
google::protobuf::RepeatedField<CPPTYPE>* values = \
|
||||||
|
Raw<google::protobuf::RepeatedField<CPPTYPE> >(msg, offset); \
|
||||||
|
if (GOOGLE_PREDICT_FALSE( \
|
||||||
|
(!WireFormatLite::ReadPackedPrimitive< \
|
||||||
|
CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE_PACKED_TYPE(INT32, int32, Int32)
|
||||||
|
HANDLE_PACKED_TYPE(INT64, int64, Int64)
|
||||||
|
HANDLE_PACKED_TYPE(SINT32, int32, Int32)
|
||||||
|
HANDLE_PACKED_TYPE(SINT64, int64, Int64)
|
||||||
|
HANDLE_PACKED_TYPE(UINT32, uint32, UInt32)
|
||||||
|
HANDLE_PACKED_TYPE(UINT64, uint64, UInt64)
|
||||||
|
|
||||||
|
HANDLE_PACKED_TYPE(FIXED32, uint32, UInt32)
|
||||||
|
HANDLE_PACKED_TYPE(FIXED64, uint64, UInt64)
|
||||||
|
HANDLE_PACKED_TYPE(SFIXED32, int32, Int32)
|
||||||
|
HANDLE_PACKED_TYPE(SFIXED64, int64, Int64)
|
||||||
|
|
||||||
|
HANDLE_PACKED_TYPE(FLOAT, float, Float)
|
||||||
|
HANDLE_PACKED_TYPE(DOUBLE, double, Double)
|
||||||
|
|
||||||
|
HANDLE_PACKED_TYPE(BOOL, bool, Bool)
|
||||||
|
#undef HANDLE_PACKED_TYPE
|
||||||
|
case WireFormatLite::TYPE_ENUM: {
|
||||||
|
// To avoid unnecessarily calling MutableUnknownFields (which mutates
|
||||||
|
// InternalMetadataWithArena) when all inputs in the repeated series
|
||||||
|
// are valid, we implement our own parser rather than call
|
||||||
|
// WireFormat::ReadPackedEnumPreserveUnknowns.
|
||||||
|
uint32 length;
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!input->ReadVarint32(&length))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuxillaryParseTableField::EnumValidator validator =
|
||||||
|
table.aux[field_number].enums.validator;
|
||||||
|
google::protobuf::RepeatedField<int>* values =
|
||||||
|
Raw<google::protobuf::RepeatedField<int> >(msg, offset);
|
||||||
|
|
||||||
|
io::CodedInputStream::Limit limit = input->PushLimit(length);
|
||||||
|
while (input->BytesUntilLimit() > 0) {
|
||||||
|
int value;
|
||||||
|
if (GOOGLE_PREDICT_FALSE(
|
||||||
|
(!google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
|
int, WireFormatLite::TYPE_ENUM>(input, &value)))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validator(value)) {
|
||||||
|
values->Add(value);
|
||||||
|
} else {
|
||||||
|
// TODO(ckennelly): Consider caching here.
|
||||||
|
UnknownFieldHandler::Varint(msg, table, tag, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
input->PopLimit(limit);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WireFormatLite::TYPE_STRING:
|
||||||
|
case WireFormatLite::TYPE_GROUP:
|
||||||
|
case WireFormatLite::TYPE_MESSAGE:
|
||||||
|
case WireFormatLite::TYPE_BYTES:
|
||||||
|
GOOGLE_DCHECK(false);
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {
|
||||||
|
// Must be the end of the message.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for possible extensions
|
||||||
|
if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) {
|
||||||
|
// successfully parsed
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// process unknown field.
|
||||||
|
if (GOOGLE_PREDICT_FALSE(!UnknownFieldHandler::Skip(msg, table, input, tag))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__
|
||||||
+654
-8
@@ -35,12 +35,25 @@
|
|||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream_inl.h>
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/extension_set.h>
|
||||||
|
#include <google/protobuf/message_lite.h>
|
||||||
|
#include <google/protobuf/metadata_lite.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
#include <google/protobuf/repeated_field.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
double Infinity() {
|
double Infinity() {
|
||||||
return std::numeric_limits<double>::infinity();
|
return std::numeric_limits<double>::infinity();
|
||||||
}
|
}
|
||||||
@@ -51,16 +64,14 @@ double NaN() {
|
|||||||
ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
|
ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
|
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
|
||||||
|
|
||||||
void DeleteEmptyString() {
|
void DeleteEmptyString() { fixed_address_empty_string.Destruct(); }
|
||||||
GetEmptyStringAlreadyInited().~string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitEmptyString() {
|
void InitEmptyString() {
|
||||||
fixed_address_empty_string.DefaultConstruct();
|
fixed_address_empty_string.DefaultConstruct();
|
||||||
OnShutdown(&DeleteEmptyString);
|
OnShutdown(&DeleteEmptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringSpaceUsedExcludingSelf(const string& str) {
|
size_t StringSpaceUsedExcludingSelfLong(const string& str) {
|
||||||
const void* start = &str;
|
const void* start = &str;
|
||||||
const void* end = &str + 1;
|
const void* end = &str + 1;
|
||||||
if (start <= str.data() && str.data() < end) {
|
if (start <= str.data() && str.data() < end) {
|
||||||
@@ -73,10 +84,645 @@ int StringSpaceUsedExcludingSelf(const string& str) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MergeFromFail(const char* file, int line) {
|
void InitProtobufDefaults() {
|
||||||
GOOGLE_CHECK(false) << file << ":" << line;
|
GetEmptyString();
|
||||||
// Open-source GOOGLE_CHECK(false) is not NORETURN.
|
}
|
||||||
exit(1);
|
|
||||||
|
template <typename T>
|
||||||
|
const T& Get(const void* ptr) {
|
||||||
|
return *static_cast<const T*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrimitiveTypeHelper is a wrapper around the interface of WireFormatLite.
|
||||||
|
// WireFormatLite has a very inconvenient interface with respect to template
|
||||||
|
// meta-programming. This class wraps the different named functions into
|
||||||
|
// a single Serialize / SerializeToArray interface.
|
||||||
|
template <int type>
|
||||||
|
struct PrimitiveTypeHelper;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_BOOL> {
|
||||||
|
typedef bool Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteBoolNoTag(Get<bool>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteBoolNoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> {
|
||||||
|
typedef int32 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteInt32NoTag(Get<int32>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteInt32NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT32> {
|
||||||
|
typedef int32 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteSInt32NoTag(Get<int32>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteSInt32NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT32> {
|
||||||
|
typedef uint32 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteUInt32NoTag(Get<uint32>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteUInt32NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT64> {
|
||||||
|
typedef int64 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteInt64NoTag(Get<int64>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteInt64NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT64> {
|
||||||
|
typedef int64 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteSInt64NoTag(Get<int64>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteSInt64NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT64> {
|
||||||
|
typedef uint64 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteUInt64NoTag(Get<uint64>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteUInt64NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> {
|
||||||
|
typedef uint32 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteFixed32NoTag(Get<uint32>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteFixed32NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> {
|
||||||
|
typedef uint64 Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
WireFormatLite::WriteFixed64NoTag(Get<uint64>(ptr), output);
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
return WireFormatLite::WriteFixed64NoTagToArray(Get<Type>(ptr), buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_ENUM>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SFIXED32>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> {
|
||||||
|
typedef int32 Type;
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SFIXED64>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> {
|
||||||
|
typedef int64 Type;
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_FLOAT>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> {
|
||||||
|
typedef float Type;
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_DOUBLE>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> {
|
||||||
|
typedef double Type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {
|
||||||
|
typedef string Type;
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
const Type& value = *static_cast<const Type*>(ptr);
|
||||||
|
output->WriteVarint32(value.size());
|
||||||
|
output->WriteRawMaybeAliased(value.data(), value.size());
|
||||||
|
}
|
||||||
|
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
|
||||||
|
const Type& value = *static_cast<const Type*>(ptr);
|
||||||
|
return io::CodedOutputStream::WriteStringWithSizeToArray(value, buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PrimitiveTypeHelper<WireFormatLite::TYPE_BYTES>
|
||||||
|
: PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
|
||||||
|
|
||||||
|
// We want to serialize to both CodedOutputStream and directly into byte arrays
|
||||||
|
// without duplicating the code. In fact we might want extra output channels in
|
||||||
|
// the future.
|
||||||
|
template <typename O, int type>
|
||||||
|
struct OutputHelper;
|
||||||
|
|
||||||
|
template <int type, typename O>
|
||||||
|
void SerializeTo(const void* ptr, O* output) {
|
||||||
|
OutputHelper<O, type>::Serialize(ptr, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename O>
|
||||||
|
void WriteTagTo(uint32 tag, O* output) {
|
||||||
|
SerializeTo<WireFormatLite::TYPE_UINT32>(&tag, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename O>
|
||||||
|
void WriteLengthTo(uint32 length, O* output) {
|
||||||
|
SerializeTo<WireFormatLite::TYPE_UINT32>(&length, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specialization for coded output stream
|
||||||
|
template <int type>
|
||||||
|
struct OutputHelper< ::google::protobuf::io::CodedOutputStream, type> {
|
||||||
|
static void Serialize(const void* ptr,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
PrimitiveTypeHelper<type>::Serialize(ptr, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Specialization for writing into a plain array
|
||||||
|
struct ArrayOutput {
|
||||||
|
uint8* ptr;
|
||||||
|
bool is_deterministic;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
struct OutputHelper<ArrayOutput, type> {
|
||||||
|
static void Serialize(const void* ptr, ArrayOutput* output) {
|
||||||
|
output->ptr = PrimitiveTypeHelper<type>::SerializeToArray(ptr, output->ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void SerializeMessageNoTable(const MessageLite* msg,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
msg->SerializeWithCachedSizes(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerializeMessageNoTable(const MessageLite* msg, ArrayOutput* output) {
|
||||||
|
output->ptr = msg->InternalSerializeWithCachedSizesToArray(
|
||||||
|
output->is_deterministic, output->ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to branch to fast path if possible
|
||||||
|
void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg,
|
||||||
|
const FieldMetadata* field_table, int num_fields,
|
||||||
|
int32 cached_size,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(&msg);
|
||||||
|
// Try the fast path
|
||||||
|
uint8* ptr = output->GetDirectBufferForNBytesAndAdvance(cached_size);
|
||||||
|
if (ptr) {
|
||||||
|
// We use virtual dispatch to enable dedicated generated code for the
|
||||||
|
// fast path.
|
||||||
|
msg.InternalSerializeWithCachedSizesToArray(
|
||||||
|
output->IsSerializationDeterministic(), ptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SerializeInternal(base, field_table, num_fields, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to branch to fast path if possible
|
||||||
|
void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg,
|
||||||
|
const FieldMetadata* field_table, int num_fields,
|
||||||
|
int32 cached_size, ArrayOutput* output) {
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(&msg);
|
||||||
|
output->ptr = SerializeInternalToArray(base, field_table, num_fields,
|
||||||
|
output->is_deterministic, output->ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serializing messages is special as it's not a primitive type and needs an
|
||||||
|
// explicit overload for each output type.
|
||||||
|
template <typename O>
|
||||||
|
void SerializeMessageTo(const MessageLite* msg, const void* table_ptr,
|
||||||
|
O* output) {
|
||||||
|
const SerializationTable* table =
|
||||||
|
static_cast<const SerializationTable*>(table_ptr);
|
||||||
|
if (!table) {
|
||||||
|
// Proto1
|
||||||
|
WriteLengthTo(msg->GetCachedSize(), output);
|
||||||
|
SerializeMessageNoTable(msg, output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const FieldMetadata* field_table = table->field_table;
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(msg);
|
||||||
|
int cached_size = *reinterpret_cast<const int32*>(base + field_table->offset);
|
||||||
|
WriteLengthTo(cached_size, output);
|
||||||
|
int num_fields = table->num_fields - 1;
|
||||||
|
SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size,
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Almost the same as above only it doesn't output the length field.
|
||||||
|
template <typename O>
|
||||||
|
void SerializeGroupTo(const MessageLite* msg, const void* table_ptr,
|
||||||
|
O* output) {
|
||||||
|
const SerializationTable* table =
|
||||||
|
static_cast<const SerializationTable*>(table_ptr);
|
||||||
|
if (!table) {
|
||||||
|
// Proto1
|
||||||
|
SerializeMessageNoTable(msg, output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const FieldMetadata* field_table = table->field_table;
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(msg);
|
||||||
|
int cached_size = *reinterpret_cast<const int32*>(base + field_table->offset);
|
||||||
|
int num_fields = table->num_fields - 1;
|
||||||
|
SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size,
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
struct SingularFieldHelper {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeTo<type>(field, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SingularFieldHelper<WireFormatLite::TYPE_STRING> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeTo<WireFormatLite::TYPE_STRING>(&Get<ArenaStringPtr>(field).Get(),
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SingularFieldHelper<WireFormatLite::TYPE_BYTES>
|
||||||
|
: SingularFieldHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SingularFieldHelper<WireFormatLite::TYPE_GROUP> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeGroupTo(Get<const MessageLite*>(field),
|
||||||
|
static_cast<const SerializationTable*>(md.ptr), output);
|
||||||
|
WriteTagTo(md.tag + 1, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SingularFieldHelper<WireFormatLite::TYPE_MESSAGE> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeMessageTo(Get<const MessageLite*>(field),
|
||||||
|
static_cast<const SerializationTable*>(md.ptr), output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
struct RepeatedFieldHelper {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
typedef typename PrimitiveTypeHelper<type>::Type T;
|
||||||
|
const RepeatedField<T>& array = Get<RepeatedField<T> >(field);
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeTo<type>(&array[i], output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// We need to use a helper class to get access to the private members
|
||||||
|
class AccessorHelper {
|
||||||
|
public:
|
||||||
|
static int Size(const RepeatedPtrFieldBase& x) { return x.size(); }
|
||||||
|
static void const* Get(const RepeatedPtrFieldBase& x, int idx) {
|
||||||
|
return x.raw_data()[idx];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
const internal::RepeatedPtrFieldBase& array =
|
||||||
|
Get<internal::RepeatedPtrFieldBase>(field);
|
||||||
|
for (int i = 0; i < AccessorHelper::Size(array); i++) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeTo<WireFormatLite::TYPE_STRING>(AccessorHelper::Get(array, i),
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct RepeatedFieldHelper<WireFormatLite::TYPE_BYTES>
|
||||||
|
: RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct RepeatedFieldHelper<WireFormatLite::TYPE_GROUP> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
const internal::RepeatedPtrFieldBase& array =
|
||||||
|
Get<internal::RepeatedPtrFieldBase>(field);
|
||||||
|
for (int i = 0; i < AccessorHelper::Size(array); i++) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeGroupTo(
|
||||||
|
static_cast<const MessageLite*>(AccessorHelper::Get(array, i)),
|
||||||
|
static_cast<const SerializationTable*>(md.ptr), output);
|
||||||
|
WriteTagTo(md.tag + 1, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct RepeatedFieldHelper<WireFormatLite::TYPE_MESSAGE> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
const internal::RepeatedPtrFieldBase& array =
|
||||||
|
Get<internal::RepeatedPtrFieldBase>(field);
|
||||||
|
for (int i = 0; i < AccessorHelper::Size(array); i++) {
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
SerializeMessageTo(
|
||||||
|
static_cast<const MessageLite*>(AccessorHelper::Get(array, i)), md.ptr,
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
struct PackedFieldHelper {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
typedef typename PrimitiveTypeHelper<type>::Type T;
|
||||||
|
const RepeatedField<T>& array = Get<RepeatedField<T> >(field);
|
||||||
|
if (array.empty()) return;
|
||||||
|
WriteTagTo(md.tag, output);
|
||||||
|
int cached_size =
|
||||||
|
Get<int>(static_cast<const uint8*>(field) + sizeof(RepeatedField<T>));
|
||||||
|
WriteLengthTo(cached_size, output);
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
SerializeTo<type>(&array[i], output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PackedFieldHelper<WireFormatLite::TYPE_STRING> {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
GOOGLE_LOG(FATAL) << "Not implemented field number " << md.tag << " with type "
|
||||||
|
<< md.type;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct PackedFieldHelper<WireFormatLite::TYPE_BYTES>
|
||||||
|
: PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
template <>
|
||||||
|
struct PackedFieldHelper<WireFormatLite::TYPE_GROUP>
|
||||||
|
: PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
template <>
|
||||||
|
struct PackedFieldHelper<WireFormatLite::TYPE_MESSAGE>
|
||||||
|
: PackedFieldHelper<WireFormatLite::TYPE_STRING> {};
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
struct OneOfFieldHelper {
|
||||||
|
template <typename O>
|
||||||
|
static void Serialize(const void* field, const FieldMetadata& md, O* output) {
|
||||||
|
SingularFieldHelper<type>::Serialize(field, md, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void SerializeNotImplemented(int field) {
|
||||||
|
GOOGLE_LOG(FATAL) << "Not implemented field number " << field;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When switching to c++11 we should make these constexpr functions
|
||||||
|
#define SERIALIZE_TABLE_OP(type, type_class) \
|
||||||
|
((type - 1) + static_cast<int>(type_class) * FieldMetadata::kNumTypes)
|
||||||
|
|
||||||
|
int FieldMetadata::CalculateType(int type,
|
||||||
|
FieldMetadata::FieldTypeClass type_class) {
|
||||||
|
return SERIALIZE_TABLE_OP(type, type_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <int type>
|
||||||
|
bool IsNull(const void* ptr) {
|
||||||
|
return *static_cast<const typename PrimitiveTypeHelper<type>::Type*>(ptr) ==
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool IsNull<WireFormatLite::TYPE_STRING>(const void* ptr) {
|
||||||
|
return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool IsNull<WireFormatLite::TYPE_BYTES>(const void* ptr) {
|
||||||
|
return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool IsNull<WireFormatLite::TYPE_GROUP>(const void* ptr) {
|
||||||
|
return Get<const MessageLite*>(ptr) == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool IsNull<WireFormatLite::TYPE_MESSAGE>(const void* ptr) {
|
||||||
|
return Get<const MessageLite*>(ptr) == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define SERIALIZERS_FOR_TYPE(type) \
|
||||||
|
case SERIALIZE_TABLE_OP(type, FieldMetadata::kPresence): \
|
||||||
|
if (!IsPresent(base, field_metadata.has_offset)) continue; \
|
||||||
|
SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \
|
||||||
|
break; \
|
||||||
|
case SERIALIZE_TABLE_OP(type, FieldMetadata::kNoPresence): \
|
||||||
|
if (IsNull<type>(ptr)) continue; \
|
||||||
|
SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \
|
||||||
|
break; \
|
||||||
|
case SERIALIZE_TABLE_OP(type, FieldMetadata::kRepeated): \
|
||||||
|
RepeatedFieldHelper<type>::Serialize(ptr, field_metadata, output); \
|
||||||
|
break; \
|
||||||
|
case SERIALIZE_TABLE_OP(type, FieldMetadata::kPacked): \
|
||||||
|
PackedFieldHelper<type>::Serialize(ptr, field_metadata, output); \
|
||||||
|
break; \
|
||||||
|
case SERIALIZE_TABLE_OP(type, FieldMetadata::kOneOf): \
|
||||||
|
if (!IsOneofPresent(base, field_metadata.has_offset, field_metadata.tag)) \
|
||||||
|
continue; \
|
||||||
|
OneOfFieldHelper<type>::Serialize(ptr, field_metadata, output); \
|
||||||
|
break
|
||||||
|
|
||||||
|
void SerializeInternal(const uint8* base,
|
||||||
|
const FieldMetadata* field_metadata_table,
|
||||||
|
int32 num_fields,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
for (int i = 0; i < num_fields; i++) {
|
||||||
|
const FieldMetadata& field_metadata = field_metadata_table[i];
|
||||||
|
const uint8* ptr = base + field_metadata.offset;
|
||||||
|
switch (field_metadata.type) {
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64);
|
||||||
|
|
||||||
|
// Special cases
|
||||||
|
case FieldMetadata::kSpecial:
|
||||||
|
reinterpret_cast<SpecialSerializer>(
|
||||||
|
const_cast<void*>(field_metadata.ptr))(
|
||||||
|
base, field_metadata.offset, field_metadata.tag,
|
||||||
|
field_metadata.has_offset, output);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// __builtin_unreachable()
|
||||||
|
SerializeNotImplemented(field_metadata.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8* SerializeInternalToArray(const uint8* base,
|
||||||
|
const FieldMetadata* field_metadata_table,
|
||||||
|
int32 num_fields, bool is_deterministic,
|
||||||
|
uint8* buffer) {
|
||||||
|
ArrayOutput array_output = {buffer, is_deterministic};
|
||||||
|
ArrayOutput* output = &array_output;
|
||||||
|
for (int i = 0; i < num_fields; i++) {
|
||||||
|
const FieldMetadata& field_metadata = field_metadata_table[i];
|
||||||
|
const uint8* ptr = base + field_metadata.offset;
|
||||||
|
switch (field_metadata.type) {
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32);
|
||||||
|
SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64);
|
||||||
|
// Special cases
|
||||||
|
case FieldMetadata::kSpecial: {
|
||||||
|
io::ArrayOutputStream array_stream(array_output.ptr, INT_MAX);
|
||||||
|
io::CodedOutputStream output(&array_stream);
|
||||||
|
output.SetSerializationDeterministic(is_deterministic);
|
||||||
|
reinterpret_cast<SpecialSerializer>(
|
||||||
|
const_cast<void*>(field_metadata.ptr))(
|
||||||
|
base, field_metadata.offset, field_metadata.tag,
|
||||||
|
field_metadata.has_offset, &output);
|
||||||
|
array_output.ptr += output.ByteCount();
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
// __builtin_unreachable()
|
||||||
|
SerializeNotImplemented(field_metadata.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array_output.ptr;
|
||||||
|
}
|
||||||
|
#undef SERIALIZERS_FOR_TYPE
|
||||||
|
|
||||||
|
void ExtensionSerializer(const uint8* ptr, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
reinterpret_cast<const ExtensionSet*>(ptr + offset)
|
||||||
|
->SerializeWithCachedSizes(tag, has_offset, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnknownFieldSerializerLite(const uint8* ptr, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
output->WriteString(
|
||||||
|
reinterpret_cast<const InternalMetadataWithArenaLite*>(ptr + offset)
|
||||||
|
->unknown_fields());
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageLite* DuplicateIfNonNullInternal(MessageLite* message, Arena* arena) {
|
||||||
|
if (message) {
|
||||||
|
MessageLite* ret = message->New(arena);
|
||||||
|
ret->CheckTypeAndMergeFrom(*message);
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a message owned by this Arena. This may require Own()ing or
|
||||||
|
// duplicating the message.
|
||||||
|
MessageLite* GetOwnedMessageInternal(Arena* message_arena,
|
||||||
|
MessageLite* submessage,
|
||||||
|
Arena* submessage_arena) {
|
||||||
|
GOOGLE_DCHECK(submessage->GetArena() == submessage_arena);
|
||||||
|
GOOGLE_DCHECK(message_arena != submessage_arena);
|
||||||
|
if (message_arena != NULL && submessage_arena == NULL) {
|
||||||
|
message_arena->Own(submessage);
|
||||||
|
return submessage;
|
||||||
|
} else {
|
||||||
|
MessageLite* ret = submessage->New(message_arena);
|
||||||
|
ret->CheckTypeAndMergeFrom(*submessage);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|||||||
+224
-73
@@ -39,17 +39,24 @@
|
|||||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
|
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <climits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/logging.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/once.h>
|
#include <google/protobuf/stubs/once.h>
|
||||||
#include <google/protobuf/has_bits.h>
|
#include <google/protobuf/has_bits.h>
|
||||||
|
#include <google/protobuf/map_entry_lite.h>
|
||||||
|
#include <google/protobuf/message_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
class Arena;
|
class Arena;
|
||||||
|
|
||||||
namespace io { class CodedInputStream; }
|
namespace io { class CodedInputStream; }
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -67,66 +74,39 @@ namespace internal {
|
|||||||
#define GOOGLE_PROTOBUF_DEPRECATED_ATTR
|
#define GOOGLE_PROTOBUF_DEPRECATED_ATTR
|
||||||
|
|
||||||
|
|
||||||
|
// Returns the offset of the given field within the given aggregate type.
|
||||||
|
// This is equivalent to the ANSI C offsetof() macro. However, according
|
||||||
|
// to the C++ standard, offsetof() only works on POD types, and GCC
|
||||||
|
// enforces this requirement with a warning. In practice, this rule is
|
||||||
|
// unnecessarily strict; there is probably no compiler or platform on
|
||||||
|
// which the offsets of the direct fields of a class are non-constant.
|
||||||
|
// Fields inherited from superclasses *can* have non-constant offsets,
|
||||||
|
// but that's not what this macro will be used for.
|
||||||
|
#if defined(__clang__)
|
||||||
|
// For Clang we use __builtin_offsetof() and suppress the warning,
|
||||||
|
// to avoid Control Flow Integrity and UBSan vptr sanitizers from
|
||||||
|
// crashing while trying to validate the invalid reinterpet_casts.
|
||||||
|
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
|
||||||
|
__builtin_offsetof(TYPE, FIELD) \
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
#else
|
||||||
|
// Note that we calculate relative to the pointer value 16 here since if we
|
||||||
|
// just use zero, GCC complains about dereferencing a NULL pointer. We
|
||||||
|
// choose 16 rather than some other number just in case the compiler would
|
||||||
|
// be confused by an unaligned pointer.
|
||||||
|
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
|
||||||
|
static_cast< ::google::protobuf::uint32>( \
|
||||||
|
reinterpret_cast<const char*>( \
|
||||||
|
&reinterpret_cast<const TYPE*>(16)->FIELD) - \
|
||||||
|
reinterpret_cast<const char*>(16))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Constants for special floating point values.
|
// Constants for special floating point values.
|
||||||
LIBPROTOBUF_EXPORT double Infinity();
|
LIBPROTOBUF_EXPORT double Infinity();
|
||||||
LIBPROTOBUF_EXPORT double NaN();
|
LIBPROTOBUF_EXPORT double NaN();
|
||||||
|
|
||||||
// This type is used to define a global variable, without it's constructor
|
|
||||||
// and destructor run on start and end of the program lifetime. This circumvents
|
|
||||||
// the initial construction order fiasco, while keeping the address of the
|
|
||||||
// empty string a compile time constant.
|
|
||||||
template <typename T>
|
|
||||||
class ExplicitlyConstructed {
|
|
||||||
public:
|
|
||||||
void DefaultConstruct() {
|
|
||||||
new (&union_) T();
|
|
||||||
init_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsInitialized() { return init_; }
|
|
||||||
void Shutdown() {
|
|
||||||
if (init_) {
|
|
||||||
init_ = false;
|
|
||||||
get_mutable()->~T();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& get() const { return reinterpret_cast<const T&>(union_); }
|
|
||||||
T* get_mutable() { return reinterpret_cast<T*>(&union_); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Prefer c++14 aligned_storage, but for compatibility this will do.
|
|
||||||
union AlignedUnion {
|
|
||||||
char space[sizeof(T)];
|
|
||||||
int64 align_to_int64;
|
|
||||||
void* align_to_ptr;
|
|
||||||
} union_;
|
|
||||||
bool init_; // false by linker
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(jieluo): Change to template. We have tried to use template,
|
|
||||||
// but it causes net/rpc/python:rpcutil_test fail (the empty string will
|
|
||||||
// init twice). It may related to swig. Change to template after we
|
|
||||||
// found the solution.
|
|
||||||
|
|
||||||
// Default empty string object. Don't use this directly. Instead, call
|
|
||||||
// GetEmptyString() to get the reference.
|
|
||||||
extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
|
|
||||||
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
|
|
||||||
LIBPROTOBUF_EXPORT void InitEmptyString();
|
|
||||||
|
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {
|
|
||||||
return fixed_address_empty_string.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
|
|
||||||
return GetEmptyStringAlreadyInited();
|
|
||||||
}
|
|
||||||
|
|
||||||
LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str);
|
|
||||||
|
|
||||||
|
|
||||||
// True if IsInitialized() is true for all elements of t. Type is expected
|
// True if IsInitialized() is true for all elements of t. Type is expected
|
||||||
// to be a RepeatedPtrField<some message type>. It's useful to have this
|
// to be a RepeatedPtrField<some message type>. It's useful to have this
|
||||||
@@ -140,26 +120,197 @@ template <class Type> bool AllAreInitialized(const Type& t) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to crash on merge failure.
|
LIBPROTOBUF_EXPORT void InitProtobufDefaults();
|
||||||
// Moved out of generated code to reduce binary size.
|
|
||||||
LIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
|
|
||||||
// We compute sizes as size_t but cache them as int. This function converts a
|
struct LIBPROTOBUF_EXPORT FieldMetadata {
|
||||||
// computed size to a cached size. Since we don't proceed with serialization if
|
uint32 offset; // offset of this field in the struct
|
||||||
// the total size was > INT_MAX, it is not important what this function returns
|
uint32 tag; // field * 8 + wire_type
|
||||||
// for inputs > INT_MAX.
|
// byte offset * 8 + bit_offset;
|
||||||
inline int ToCachedSize(size_t size) {
|
// if the high bit is set then this is the byte offset of the oneof_case
|
||||||
return static_cast<int>(size);
|
// for this field.
|
||||||
|
uint32 has_offset;
|
||||||
|
uint32 type; // the type of this field.
|
||||||
|
const void* ptr; // auxiliary data
|
||||||
|
|
||||||
|
// From the serializer point of view each fundamental type can occur in
|
||||||
|
// 4 different ways. For simplicity we treat all combinations as a cartesion
|
||||||
|
// product although not all combinations are allowed.
|
||||||
|
enum FieldTypeClass {
|
||||||
|
kPresence,
|
||||||
|
kNoPresence,
|
||||||
|
kRepeated,
|
||||||
|
kPacked,
|
||||||
|
kOneOf,
|
||||||
|
kNumTypeClasses // must be last enum
|
||||||
|
};
|
||||||
|
// C++ protobuf has 20 fundamental types, were we added Cord and StringPiece
|
||||||
|
// and also distinquish the same types if they have different wire format.
|
||||||
|
enum {
|
||||||
|
kCordType = 19,
|
||||||
|
kStringPieceType = 20,
|
||||||
|
kNumTypes = 20,
|
||||||
|
kSpecial = kNumTypes * kNumTypeClasses,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int CalculateType(int fundamental_type, FieldTypeClass type_class);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool IsPresent(const void* base, uint32 hasbit) {
|
||||||
|
const uint32* has_bits_array = static_cast<const uint32*>(base);
|
||||||
|
return has_bits_array[hasbit / 32] & (1u << (hasbit & 31));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We mainly calculate sizes in terms of size_t, but some functions that compute
|
inline bool IsOneofPresent(const void* base, uint32 offset, uint32 tag) {
|
||||||
// sizes return "int". These int sizes are expected to always be positive.
|
const uint32* oneof =
|
||||||
// This function is more efficient than casting an int to size_t directly on
|
reinterpret_cast<const uint32*>(static_cast<const uint8*>(base) + offset);
|
||||||
// 64-bit platforms because it avoids making the compiler emit a sign extending
|
return *oneof == tag >> 3;
|
||||||
// instruction, which we don't want and don't want to pay for.
|
}
|
||||||
inline size_t FromIntSize(int size) {
|
|
||||||
// Convert to unsigned before widening so sign extension is not necessary.
|
typedef void (*SpecialSerializer)(const uint8* base, uint32 offset, uint32 tag,
|
||||||
return static_cast<unsigned int>(size);
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output);
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT void ExtensionSerializer(const uint8* base, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output);
|
||||||
|
LIBPROTOBUF_EXPORT void UnknownFieldSerializerLite(const uint8* base, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output);
|
||||||
|
|
||||||
|
struct SerializationTable {
|
||||||
|
int num_fields;
|
||||||
|
const FieldMetadata* field_table;
|
||||||
|
};
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT void SerializeInternal(const uint8* base, const FieldMetadata* table,
|
||||||
|
int num_fields, ::google::protobuf::io::CodedOutputStream* output);
|
||||||
|
|
||||||
|
inline void TableSerialize(const ::google::protobuf::MessageLite& msg,
|
||||||
|
const SerializationTable* table,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
const FieldMetadata* field_table = table->field_table;
|
||||||
|
int num_fields = table->num_fields - 1;
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(&msg);
|
||||||
|
// TODO(gerbens) This skips the first test if we could use the fast
|
||||||
|
// array serialization path, we should make this
|
||||||
|
// int cached_size =
|
||||||
|
// *reinterpret_cast<const int32*>(base + field_table->offset);
|
||||||
|
// SerializeWithCachedSize(msg, field_table + 1, num_fields, cached_size, ...)
|
||||||
|
// But we keep conformance with the old way for now.
|
||||||
|
SerializeInternal(base, field_table + 1, num_fields, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8* SerializeInternalToArray(const uint8* base, const FieldMetadata* table,
|
||||||
|
int num_fields, bool is_deterministic,
|
||||||
|
uint8* buffer);
|
||||||
|
|
||||||
|
inline uint8* TableSerializeToArray(const ::google::protobuf::MessageLite& msg,
|
||||||
|
const SerializationTable* table,
|
||||||
|
bool is_deterministic, uint8* buffer) {
|
||||||
|
const uint8* base = reinterpret_cast<const uint8*>(&msg);
|
||||||
|
const FieldMetadata* field_table = table->field_table + 1;
|
||||||
|
int num_fields = table->num_fields - 1;
|
||||||
|
return SerializeInternalToArray(base, field_table, num_fields,
|
||||||
|
is_deterministic, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct CompareHelper {
|
||||||
|
bool operator()(const T& a, const T& b) { return a < b; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct CompareHelper<ArenaStringPtr> {
|
||||||
|
bool operator()(const ArenaStringPtr& a, const ArenaStringPtr& b) {
|
||||||
|
return a.Get() < b.Get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CompareMapKey {
|
||||||
|
template <typename T>
|
||||||
|
bool operator()(const MapEntryHelper<T>& a, const MapEntryHelper<T>& b) {
|
||||||
|
return Compare(a.key_, b.key_);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool Compare(const T& a, const T& b) {
|
||||||
|
return CompareHelper<T>()(a, b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename MapFieldType, const SerializationTable* table>
|
||||||
|
void MapFieldSerializer(const uint8* base, uint32 offset, uint32 tag,
|
||||||
|
uint32 has_offset,
|
||||||
|
::google::protobuf::io::CodedOutputStream* output) {
|
||||||
|
typedef MapEntryHelper<typename MapFieldType::EntryTypeTrait> Entry;
|
||||||
|
typedef typename MapFieldType::MapType::const_iterator Iter;
|
||||||
|
|
||||||
|
const MapFieldType& map_field =
|
||||||
|
*reinterpret_cast<const MapFieldType*>(base + offset);
|
||||||
|
const SerializationTable* t =
|
||||||
|
table +
|
||||||
|
has_offset; // has_offset is overloaded for maps to mean table offset
|
||||||
|
if (!output->IsSerializationDeterministic()) {
|
||||||
|
for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end();
|
||||||
|
++it) {
|
||||||
|
Entry map_entry(*it);
|
||||||
|
output->WriteVarint32(tag);
|
||||||
|
output->WriteVarint32(map_entry._cached_size_);
|
||||||
|
SerializeInternal(reinterpret_cast<const uint8*>(&map_entry),
|
||||||
|
t->field_table, t->num_fields, output);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::vector<Entry> v;
|
||||||
|
for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end();
|
||||||
|
++it) {
|
||||||
|
v.push_back(Entry(*it));
|
||||||
|
}
|
||||||
|
std::sort(v.begin(), v.end(), CompareMapKey());
|
||||||
|
for (int i = 0; i < v.size(); i++) {
|
||||||
|
output->WriteVarint32(tag);
|
||||||
|
output->WriteVarint32(v[i]._cached_size_);
|
||||||
|
SerializeInternal(reinterpret_cast<const uint8*>(&v[i]), t->field_table,
|
||||||
|
t->num_fields, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT MessageLite* DuplicateIfNonNullInternal(MessageLite* message, Arena* arena);
|
||||||
|
LIBPROTOBUF_EXPORT MessageLite* GetOwnedMessageInternal(Arena* message_arena,
|
||||||
|
MessageLite* submessage,
|
||||||
|
Arena* submessage_arena);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T* DuplicateIfNonNull(T* message, Arena* arena) {
|
||||||
|
// The casts must be reinterpret_cast<> because T might be a forward-declared
|
||||||
|
// type that the compiler doesn't know is related to MessageLite.
|
||||||
|
return reinterpret_cast<T*>(DuplicateIfNonNullInternal(
|
||||||
|
reinterpret_cast<MessageLite*>(message), arena));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T* GetOwnedMessage(Arena* message_arena, T* submessage,
|
||||||
|
Arena* submessage_arena) {
|
||||||
|
// The casts must be reinterpret_cast<> because T might be a forward-declared
|
||||||
|
// type that the compiler doesn't know is related to MessageLite.
|
||||||
|
return reinterpret_cast<T*>(GetOwnedMessageInternal(
|
||||||
|
message_arena, reinterpret_cast<MessageLite*>(submessage),
|
||||||
|
submessage_arena));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a message owned by this Arena. This may require Own()ing or
|
||||||
|
// duplicating the message.
|
||||||
|
template <typename T>
|
||||||
|
T* GetOwnedMessage(T* message, Arena* arena) {
|
||||||
|
GOOGLE_DCHECK(message);
|
||||||
|
Arena* message_arena = google::protobuf::Arena::GetArena(message);
|
||||||
|
if (message_arena == arena) {
|
||||||
|
return message;
|
||||||
|
} else if (arena != NULL && message_arena == NULL) {
|
||||||
|
arena->Own(message);
|
||||||
|
return message;
|
||||||
|
} else {
|
||||||
|
return DuplicateIfNonNull(message, arena);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|||||||
+37
-4
@@ -32,6 +32,7 @@
|
|||||||
#define GOOGLE_PROTOBUF_HAS_BITS_H__
|
#define GOOGLE_PROTOBUF_HAS_BITS_H__
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
@@ -40,17 +41,18 @@ namespace internal {
|
|||||||
template<size_t doublewords>
|
template<size_t doublewords>
|
||||||
class HasBits {
|
class HasBits {
|
||||||
public:
|
public:
|
||||||
HasBits() GOOGLE_ATTRIBUTE_ALWAYS_INLINE { Clear(); }
|
HasBits() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE { Clear(); }
|
||||||
|
|
||||||
void Clear() GOOGLE_ATTRIBUTE_ALWAYS_INLINE {
|
void Clear() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
|
||||||
memset(has_bits_, 0, sizeof(has_bits_));
|
memset(has_bits_, 0, sizeof(has_bits_));
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::uint32& operator[](int index) GOOGLE_ATTRIBUTE_ALWAYS_INLINE {
|
::google::protobuf::uint32& operator[](int index) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
|
||||||
return has_bits_[index];
|
return has_bits_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ::google::protobuf::uint32& operator[](int index) const GOOGLE_ATTRIBUTE_ALWAYS_INLINE {
|
const ::google::protobuf::uint32& operator[](int index) const
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
|
||||||
return has_bits_[index];
|
return has_bits_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,10 +63,41 @@ class HasBits {
|
|||||||
bool operator!=(const HasBits<doublewords>& rhs) const {
|
bool operator!=(const HasBits<doublewords>& rhs) const {
|
||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::google::protobuf::uint32 has_bits_[doublewords];
|
::google::protobuf::uint32 has_bits_[doublewords];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline bool HasBits<1>::empty() const {
|
||||||
|
return !has_bits_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline bool HasBits<2>::empty() const {
|
||||||
|
return !(has_bits_[0] | has_bits_[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline bool HasBits<3>::empty() const {
|
||||||
|
return !(has_bits_[0] | has_bits_[1] | has_bits_[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline bool HasBits<4>::empty() const {
|
||||||
|
return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t doublewords>
|
||||||
|
inline bool HasBits<doublewords>::empty() const {
|
||||||
|
for (size_t i = 0; i < doublewords; ++i) {
|
||||||
|
if (has_bits_[i]) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|||||||
+29
-167
@@ -47,7 +47,6 @@
|
|||||||
#include <google/protobuf/stubs/logging.h>
|
#include <google/protobuf/stubs/logging.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/stl_util.h>
|
#include <google/protobuf/stubs/stl_util.h>
|
||||||
#include <google/protobuf/stubs/port.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
@@ -77,10 +76,6 @@ CodedInputStream::~CodedInputStream() {
|
|||||||
if (input_ != NULL) {
|
if (input_ != NULL) {
|
||||||
BackUpInputToCurrentPosition();
|
BackUpInputToCurrentPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_bytes_warning_threshold_ == -2) {
|
|
||||||
GOOGLE_LOG(WARNING) << "The total number of bytes read was " << total_bytes_read_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static.
|
// Static.
|
||||||
@@ -124,21 +119,15 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {
|
|||||||
Limit old_limit = current_limit_;
|
Limit old_limit = current_limit_;
|
||||||
|
|
||||||
// security: byte_limit is possibly evil, so check for negative values
|
// security: byte_limit is possibly evil, so check for negative values
|
||||||
// and overflow.
|
// and overflow. Also check that the new requested limit is before the
|
||||||
if (byte_limit >= 0 &&
|
// previous limit; otherwise we continue to enforce the previous limit.
|
||||||
byte_limit <= INT_MAX - current_position) {
|
if GOOGLE_PREDICT_TRUE(byte_limit >= 0 &&
|
||||||
|
byte_limit <= INT_MAX - current_position &&
|
||||||
|
byte_limit < current_limit_ - current_position) {
|
||||||
current_limit_ = current_position + byte_limit;
|
current_limit_ = current_position + byte_limit;
|
||||||
} else {
|
RecomputeBufferLimits();
|
||||||
// Negative or overflow.
|
|
||||||
current_limit_ = INT_MAX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to enforce all limits, not just the new one, so if the previous
|
|
||||||
// limit was before the new requested limit, we continue to enforce the
|
|
||||||
// previous limit.
|
|
||||||
current_limit_ = std::min(current_limit_, old_limit);
|
|
||||||
|
|
||||||
RecomputeBufferLimits();
|
|
||||||
return old_limit;
|
return old_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,16 +175,12 @@ int CodedInputStream::BytesUntilLimit() const {
|
|||||||
|
|
||||||
void CodedInputStream::SetTotalBytesLimit(
|
void CodedInputStream::SetTotalBytesLimit(
|
||||||
int total_bytes_limit, int warning_threshold) {
|
int total_bytes_limit, int warning_threshold) {
|
||||||
|
(void) warning_threshold;
|
||||||
|
|
||||||
// Make sure the limit isn't already past, since this could confuse other
|
// Make sure the limit isn't already past, since this could confuse other
|
||||||
// code.
|
// code.
|
||||||
int current_position = CurrentPosition();
|
int current_position = CurrentPosition();
|
||||||
total_bytes_limit_ = std::max(current_position, total_bytes_limit);
|
total_bytes_limit_ = std::max(current_position, total_bytes_limit);
|
||||||
if (warning_threshold >= 0) {
|
|
||||||
total_bytes_warning_threshold_ = warning_threshold;
|
|
||||||
} else {
|
|
||||||
// warning_threshold is negative
|
|
||||||
total_bytes_warning_threshold_ = -1;
|
|
||||||
}
|
|
||||||
RecomputeBufferLimits();
|
RecomputeBufferLimits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,17 +197,7 @@ void CodedInputStream::PrintTotalBytesLimitError() {
|
|||||||
"in google/protobuf/io/coded_stream.h.";
|
"in google/protobuf/io/coded_stream.h.";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodedInputStream::Skip(int count) {
|
bool CodedInputStream::SkipFallback(int count, int original_buffer_size) {
|
||||||
if (count < 0) return false; // security: count is often user-supplied
|
|
||||||
|
|
||||||
const int original_buffer_size = BufferSize();
|
|
||||||
|
|
||||||
if (count <= original_buffer_size) {
|
|
||||||
// Just skipping within the current buffer. Easy.
|
|
||||||
Advance(count);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_size_after_limit_ > 0) {
|
if (buffer_size_after_limit_ > 0) {
|
||||||
// We hit a limit inside this buffer. Advance to the limit and fail.
|
// We hit a limit inside this buffer. Advance to the limit and fail.
|
||||||
Advance(original_buffer_size);
|
Advance(original_buffer_size);
|
||||||
@@ -340,7 +315,8 @@ namespace {
|
|||||||
// The first part of the pair is true iff the read was successful. The second
|
// The first part of the pair is true iff the read was successful. The second
|
||||||
// part is buffer + (number of bytes read). This function is always inlined,
|
// part is buffer + (number of bytes read). This function is always inlined,
|
||||||
// so returning a pair is costless.
|
// so returning a pair is costless.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE ::std::pair<bool, const uint8*> ReadVarint32FromArray(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
::std::pair<bool, const uint8*> ReadVarint32FromArray(
|
||||||
uint32 first_byte, const uint8* buffer,
|
uint32 first_byte, const uint8* buffer,
|
||||||
uint32* value);
|
uint32* value);
|
||||||
inline ::std::pair<bool, const uint8*> ReadVarint32FromArray(
|
inline ::std::pair<bool, const uint8*> ReadVarint32FromArray(
|
||||||
@@ -377,8 +353,8 @@ inline ::std::pair<bool, const uint8*> ReadVarint32FromArray(
|
|||||||
return std::make_pair(true, ptr);
|
return std::make_pair(true, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*> ReadVarint64FromArray(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*>
|
||||||
const uint8* buffer, uint64* value);
|
ReadVarint64FromArray(const uint8* buffer, uint64* value);
|
||||||
inline ::std::pair<bool, const uint8*> ReadVarint64FromArray(
|
inline ::std::pair<bool, const uint8*> ReadVarint64FromArray(
|
||||||
const uint8* buffer, uint64* value) {
|
const uint8* buffer, uint64* value) {
|
||||||
const uint8* ptr = buffer;
|
const uint8* ptr = buffer;
|
||||||
@@ -550,9 +526,15 @@ bool CodedInputStream::ReadVarint64Slow(uint64* value) {
|
|||||||
uint32 b;
|
uint32 b;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (count == kMaxVarintBytes) return false;
|
if (count == kMaxVarintBytes) {
|
||||||
|
*value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
while (buffer_ == buffer_end_) {
|
while (buffer_ == buffer_end_) {
|
||||||
if (!Refresh()) return false;
|
if (!Refresh()) {
|
||||||
|
*value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b = *buffer_;
|
b = *buffer_;
|
||||||
result |= static_cast<uint64>(b & 0x7F) << (7 * count);
|
result |= static_cast<uint64>(b & 0x7F) << (7 * count);
|
||||||
@@ -577,7 +559,7 @@ std::pair<uint64, bool> CodedInputStream::ReadVarint64Fallback() {
|
|||||||
buffer_ = p.second;
|
buffer_ = p.second;
|
||||||
return std::make_pair(temp, true);
|
return std::make_pair(temp, true);
|
||||||
} else {
|
} else {
|
||||||
uint64 temp = 0;
|
uint64 temp;
|
||||||
bool success = ReadVarint64Slow(&temp);
|
bool success = ReadVarint64Slow(&temp);
|
||||||
return std::make_pair(temp, success);
|
return std::make_pair(temp, success);
|
||||||
}
|
}
|
||||||
@@ -600,20 +582,6 @@ bool CodedInputStream::Refresh() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_bytes_warning_threshold_ >= 0 &&
|
|
||||||
total_bytes_read_ >= total_bytes_warning_threshold_) {
|
|
||||||
GOOGLE_LOG(WARNING) << "Reading dangerously large protocol message. If the "
|
|
||||||
"message turns out to be larger than "
|
|
||||||
<< total_bytes_limit_ << " bytes, parsing will be halted "
|
|
||||||
"for security reasons. To increase the limit (or to "
|
|
||||||
"disable these warnings), see "
|
|
||||||
"CodedInputStream::SetTotalBytesLimit() in "
|
|
||||||
"google/protobuf/io/coded_stream.h.";
|
|
||||||
|
|
||||||
// Don't warn again for this stream, and print total size at the end.
|
|
||||||
total_bytes_warning_threshold_ = -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* void_buffer;
|
const void* void_buffer;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
if (NextNonEmpty(input_, &void_buffer, &buffer_size)) {
|
if (NextNonEmpty(input_, &void_buffer, &buffer_size)) {
|
||||||
@@ -650,7 +618,7 @@ bool CodedInputStream::Refresh() {
|
|||||||
|
|
||||||
// CodedOutputStream =================================================
|
// CodedOutputStream =================================================
|
||||||
|
|
||||||
bool CodedOutputStream::default_serialization_deterministic_ = false;
|
google::protobuf::internal::AtomicWord CodedOutputStream::default_serialization_deterministic_ = 0;
|
||||||
|
|
||||||
CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output)
|
CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output)
|
||||||
: output_(output),
|
: output_(output),
|
||||||
@@ -789,104 +757,12 @@ void CodedOutputStream::WriteVarint32SlowPath(uint32 value) {
|
|||||||
WriteRaw(bytes, size);
|
WriteRaw(bytes, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8* CodedOutputStream::WriteVarint64ToArrayInline(
|
void CodedOutputStream::WriteVarint64SlowPath(uint64 value) {
|
||||||
uint64 value, uint8* target) {
|
uint8 bytes[kMaxVarintBytes];
|
||||||
// Splitting into 32-bit pieces gives better performance on 32-bit
|
uint8* target = &bytes[0];
|
||||||
// processors.
|
uint8* end = WriteVarint64ToArray(value, target);
|
||||||
uint32 part0 = static_cast<uint32>(value );
|
int size = end - target;
|
||||||
uint32 part1 = static_cast<uint32>(value >> 28);
|
WriteRaw(bytes, size);
|
||||||
uint32 part2 = static_cast<uint32>(value >> 56);
|
|
||||||
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// Here we can't really optimize for small numbers, since the value is
|
|
||||||
// split into three parts. Cheking for numbers < 128, for instance,
|
|
||||||
// would require three comparisons, since you'd have to make sure part1
|
|
||||||
// and part2 are zero. However, if the caller is using 64-bit integers,
|
|
||||||
// it is likely that they expect the numbers to often be very large, so
|
|
||||||
// we probably don't want to optimize for small numbers anyway. Thus,
|
|
||||||
// we end up with a hardcoded binary search tree...
|
|
||||||
if (part2 == 0) {
|
|
||||||
if (part1 == 0) {
|
|
||||||
if (part0 < (1 << 14)) {
|
|
||||||
if (part0 < (1 << 7)) {
|
|
||||||
size = 1; goto size1;
|
|
||||||
} else {
|
|
||||||
size = 2; goto size2;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (part0 < (1 << 21)) {
|
|
||||||
size = 3; goto size3;
|
|
||||||
} else {
|
|
||||||
size = 4; goto size4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (part1 < (1 << 14)) {
|
|
||||||
if (part1 < (1 << 7)) {
|
|
||||||
size = 5; goto size5;
|
|
||||||
} else {
|
|
||||||
size = 6; goto size6;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (part1 < (1 << 21)) {
|
|
||||||
size = 7; goto size7;
|
|
||||||
} else {
|
|
||||||
size = 8; goto size8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (part2 < (1 << 7)) {
|
|
||||||
size = 9; goto size9;
|
|
||||||
} else {
|
|
||||||
size = 10; goto size10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
|
||||||
|
|
||||||
size10: target[9] = static_cast<uint8>((part2 >> 7) | 0x80);
|
|
||||||
size9 : target[8] = static_cast<uint8>((part2 ) | 0x80);
|
|
||||||
size8 : target[7] = static_cast<uint8>((part1 >> 21) | 0x80);
|
|
||||||
size7 : target[6] = static_cast<uint8>((part1 >> 14) | 0x80);
|
|
||||||
size6 : target[5] = static_cast<uint8>((part1 >> 7) | 0x80);
|
|
||||||
size5 : target[4] = static_cast<uint8>((part1 ) | 0x80);
|
|
||||||
size4 : target[3] = static_cast<uint8>((part0 >> 21) | 0x80);
|
|
||||||
size3 : target[2] = static_cast<uint8>((part0 >> 14) | 0x80);
|
|
||||||
size2 : target[1] = static_cast<uint8>((part0 >> 7) | 0x80);
|
|
||||||
size1 : target[0] = static_cast<uint8>((part0 ) | 0x80);
|
|
||||||
|
|
||||||
target[size-1] &= 0x7F;
|
|
||||||
return target + size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CodedOutputStream::WriteVarint64(uint64 value) {
|
|
||||||
if (buffer_size_ >= kMaxVarintBytes) {
|
|
||||||
// Fast path: We have enough bytes left in the buffer to guarantee that
|
|
||||||
// this write won't cross the end, so we can skip the checks.
|
|
||||||
uint8* target = buffer_;
|
|
||||||
|
|
||||||
uint8* end = WriteVarint64ToArrayInline(value, target);
|
|
||||||
int size = end - target;
|
|
||||||
Advance(size);
|
|
||||||
} else {
|
|
||||||
// Slow path: This write might cross the end of the buffer, so we
|
|
||||||
// compose the bytes first then use WriteRaw().
|
|
||||||
uint8 bytes[kMaxVarintBytes];
|
|
||||||
int size = 0;
|
|
||||||
while (value > 0x7F) {
|
|
||||||
bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80;
|
|
||||||
value >>= 7;
|
|
||||||
}
|
|
||||||
bytes[size++] = static_cast<uint8>(value) & 0x7F;
|
|
||||||
WriteRaw(bytes, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8* CodedOutputStream::WriteVarint64ToArray(
|
|
||||||
uint64 value, uint8* target) {
|
|
||||||
return WriteVarint64ToArrayInline(value, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodedOutputStream::Refresh() {
|
bool CodedOutputStream::Refresh() {
|
||||||
@@ -903,20 +779,6 @@ bool CodedOutputStream::Refresh() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CodedOutputStream::VarintSize32Fallback(uint32 value) {
|
|
||||||
GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller.
|
|
||||||
|
|
||||||
return 1 + Bits::Log2FloorNonZero(value) / 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CodedOutputStream::VarintSize64(uint64 value) {
|
|
||||||
if (value < (1 << 7)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1 + Bits::Log2FloorNonZero64(value) / 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str,
|
uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str,
|
||||||
uint8* target) {
|
uint8* target) {
|
||||||
GOOGLE_DCHECK_LE(str.size(), kuint32max);
|
GOOGLE_DCHECK_LE(str.size(), kuint32max);
|
||||||
|
|||||||
+145
-90
@@ -110,6 +110,7 @@
|
|||||||
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
|
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <climits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -130,7 +131,10 @@
|
|||||||
#define PROTOBUF_LITTLE_ENDIAN 1
|
#define PROTOBUF_LITTLE_ENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#include <google/protobuf/stubs/atomicops.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
@@ -139,6 +143,8 @@ namespace protobuf {
|
|||||||
class DescriptorPool;
|
class DescriptorPool;
|
||||||
class MessageFactory;
|
class MessageFactory;
|
||||||
|
|
||||||
|
namespace internal { void MapTestForceDeterministic(); }
|
||||||
|
|
||||||
namespace io {
|
namespace io {
|
||||||
|
|
||||||
// Defined in this file.
|
// Defined in this file.
|
||||||
@@ -179,7 +185,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
|
|
||||||
// Skips a number of bytes. Returns false if an underlying read error
|
// Skips a number of bytes. Returns false if an underlying read error
|
||||||
// occurs.
|
// occurs.
|
||||||
bool Skip(int count);
|
inline bool Skip(int count);
|
||||||
|
|
||||||
// Sets *data to point directly at the unread part of the CodedInputStream's
|
// Sets *data to point directly at the unread part of the CodedInputStream's
|
||||||
// underlying buffer, and *size to the size of that buffer, but does not
|
// underlying buffer, and *size to the size of that buffer, but does not
|
||||||
@@ -192,28 +198,23 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
|
|
||||||
// Like GetDirectBufferPointer, but this method is inlined, and does not
|
// Like GetDirectBufferPointer, but this method is inlined, and does not
|
||||||
// attempt to Refresh() if the buffer is currently empty.
|
// attempt to Refresh() if the buffer is currently empty.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE void GetDirectBufferPointerInline(const void** data,
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
int* size);
|
void GetDirectBufferPointerInline(const void** data, int* size);
|
||||||
|
|
||||||
// Read raw bytes, copying them into the given buffer.
|
// Read raw bytes, copying them into the given buffer.
|
||||||
bool ReadRaw(void* buffer, int size);
|
bool ReadRaw(void* buffer, int size);
|
||||||
|
|
||||||
// Like the above, with inlined optimizations. This should only be used
|
// Like the above, with inlined optimizations. This should only be used
|
||||||
// by the protobuf implementation.
|
// by the protobuf implementation.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadRawInline(void* buffer, int size);
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
bool InternalReadRawInline(void* buffer, int size);
|
||||||
|
|
||||||
// Like ReadRaw, but reads into a string.
|
// Like ReadRaw, but reads into a string.
|
||||||
//
|
|
||||||
// Implementation Note: ReadString() grows the string gradually as it
|
|
||||||
// reads in the data, rather than allocating the entire requested size
|
|
||||||
// upfront. This prevents denial-of-service attacks in which a client
|
|
||||||
// could claim that a string is going to be MAX_INT bytes long in order to
|
|
||||||
// crash the server because it can't allocate this much space at once.
|
|
||||||
bool ReadString(string* buffer, int size);
|
bool ReadString(string* buffer, int size);
|
||||||
// Like the above, with inlined optimizations. This should only be used
|
// Like the above, with inlined optimizations. This should only be used
|
||||||
// by the protobuf implementation.
|
// by the protobuf implementation.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadStringInline(string* buffer,
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
int size);
|
bool InternalReadStringInline(string* buffer, int size);
|
||||||
|
|
||||||
|
|
||||||
// Read a 32-bit little-endian integer.
|
// Read a 32-bit little-endian integer.
|
||||||
@@ -249,12 +250,19 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
bool ReadVarintSizeAsInt(int* value);
|
bool ReadVarintSizeAsInt(int* value);
|
||||||
|
|
||||||
// Read a tag. This calls ReadVarint32() and returns the result, or returns
|
// Read a tag. This calls ReadVarint32() and returns the result, or returns
|
||||||
// zero (which is not a valid tag) if ReadVarint32() fails. Also, it updates
|
// zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag
|
||||||
// the last tag value, which can be checked with LastTagWas().
|
// (but not ReadTagNoLastTag) updates the last tag value, which can be checked
|
||||||
|
// with LastTagWas().
|
||||||
|
//
|
||||||
// Always inline because this is only called in one place per parse loop
|
// Always inline because this is only called in one place per parse loop
|
||||||
// but it is called for every iteration of said loop, so it should be fast.
|
// but it is called for every iteration of said loop, so it should be fast.
|
||||||
// GCC doesn't want to inline this by default.
|
// GCC doesn't want to inline this by default.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag();
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag() {
|
||||||
|
return last_tag_ = ReadTagNoLastTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag();
|
||||||
|
|
||||||
|
|
||||||
// This usually a faster alternative to ReadTag() when cutoff is a manifest
|
// This usually a faster alternative to ReadTag() when cutoff is a manifest
|
||||||
// constant. It does particularly well for cutoff >= 127. The first part
|
// constant. It does particularly well for cutoff >= 127. The first part
|
||||||
@@ -264,8 +272,15 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// above cutoff or is 0. (There's intentional wiggle room when tag is 0,
|
// above cutoff or is 0. (There's intentional wiggle room when tag is 0,
|
||||||
// because that can arise in several ways, and for best performance we want
|
// because that can arise in several ways, and for best performance we want
|
||||||
// to avoid an extra "is tag == 0?" check here.)
|
// to avoid an extra "is tag == 0?" check here.)
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
uint32 cutoff);
|
std::pair<uint32, bool> ReadTagWithCutoff(uint32 cutoff) {
|
||||||
|
std::pair<uint32, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
|
||||||
|
last_tag_ = result.first;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(uint32 cutoff);
|
||||||
|
|
||||||
// Usually returns true if calling ReadVarint32() now would produce the given
|
// Usually returns true if calling ReadVarint32() now would produce the given
|
||||||
// value. Will always return false if ReadVarint32() would not return the
|
// value. Will always return false if ReadVarint32() would not return the
|
||||||
@@ -274,7 +289,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// parameter.
|
// parameter.
|
||||||
// Always inline because this collapses to a small number of instructions
|
// Always inline because this collapses to a small number of instructions
|
||||||
// when given a constant parameter, but GCC doesn't want to inline by default.
|
// when given a constant parameter, but GCC doesn't want to inline by default.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected);
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected);
|
||||||
|
|
||||||
// Like above, except this reads from the specified buffer. The caller is
|
// Like above, except this reads from the specified buffer. The caller is
|
||||||
// responsible for ensuring that the buffer is large enough to read a varint
|
// responsible for ensuring that the buffer is large enough to read a varint
|
||||||
@@ -283,9 +298,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
//
|
//
|
||||||
// Returns a pointer beyond the expected tag if it was found, or NULL if it
|
// Returns a pointer beyond the expected tag if it was found, or NULL if it
|
||||||
// was not.
|
// was not.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE static const uint8* ExpectTagFromArray(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
const uint8* buffer,
|
static const uint8* ExpectTagFromArray(const uint8* buffer, uint32 expected);
|
||||||
uint32 expected);
|
|
||||||
|
|
||||||
// Usually returns true if no more bytes can be read. Always returns false
|
// Usually returns true if no more bytes can be read. Always returns false
|
||||||
// if more bytes can be read. If ExpectAtEnd() returns true, a subsequent
|
// if more bytes can be read. If ExpectAtEnd() returns true, a subsequent
|
||||||
@@ -293,8 +307,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// zero, and ConsumedEntireMessage() will return true.
|
// zero, and ConsumedEntireMessage() will return true.
|
||||||
bool ExpectAtEnd();
|
bool ExpectAtEnd();
|
||||||
|
|
||||||
// If the last call to ReadTag() or ReadTagWithCutoff() returned the
|
// If the last call to ReadTag() or ReadTagWithCutoff() returned the given
|
||||||
// given value, returns true. Otherwise, returns false;
|
// value, returns true. Otherwise, returns false.
|
||||||
|
// ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last
|
||||||
|
// returned value.
|
||||||
//
|
//
|
||||||
// This is needed because parsers for some types of embedded messages
|
// This is needed because parsers for some types of embedded messages
|
||||||
// (with field type TYPE_GROUP) don't actually know that they've reached the
|
// (with field type TYPE_GROUP) don't actually know that they've reached the
|
||||||
@@ -303,6 +319,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// tag to make sure it had the right number, so it calls LastTagWas() on
|
// tag to make sure it had the right number, so it calls LastTagWas() on
|
||||||
// return from the embedded parser to check.
|
// return from the embedded parser to check.
|
||||||
bool LastTagWas(uint32 expected);
|
bool LastTagWas(uint32 expected);
|
||||||
|
void SetLastTag(uint32 tag) { last_tag_ = tag; }
|
||||||
|
|
||||||
// When parsing message (but NOT a group), this method must be called
|
// When parsing message (but NOT a group), this method must be called
|
||||||
// immediately after MergeFromCodedStream() returns (if it returns true)
|
// immediately after MergeFromCodedStream() returns (if it returns true)
|
||||||
@@ -360,11 +377,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// maximum message length should be limited to the shortest length that
|
// maximum message length should be limited to the shortest length that
|
||||||
// will not harm usability. The theoretical shortest message that could
|
// will not harm usability. The theoretical shortest message that could
|
||||||
// cause integer overflows is 512MB. The default limit is 64MB. Apps
|
// cause integer overflows is 512MB. The default limit is 64MB. Apps
|
||||||
// should set shorter limits if possible. If warning_threshold is not -1,
|
// should set shorter limits if possible. For backwards compatibility all
|
||||||
// a warning will be printed to stderr after warning_threshold bytes are
|
// negative values get squashed to -1, as other negative values might have
|
||||||
// read. For backwards compatibility all negative values get squashed to -1,
|
// special internal meanings. An error will always be printed to stderr if
|
||||||
// as other negative values might have special internal meanings.
|
// the limit is reached.
|
||||||
// An error will always be printed to stderr if the limit is reached.
|
|
||||||
//
|
//
|
||||||
// This is unrelated to PushLimit()/PopLimit().
|
// This is unrelated to PushLimit()/PopLimit().
|
||||||
//
|
//
|
||||||
@@ -380,9 +396,9 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// Message::ParseFromString(). In this case, you will need to change
|
// Message::ParseFromString(). In this case, you will need to change
|
||||||
// your code to instead construct some sort of ZeroCopyInputStream
|
// your code to instead construct some sort of ZeroCopyInputStream
|
||||||
// (e.g. an ArrayInputStream), construct a CodedInputStream around
|
// (e.g. an ArrayInputStream), construct a CodedInputStream around
|
||||||
// that, then call Message::ParseFromCodedStream() instead. Then
|
// that, then you can adjust the limit. Then call
|
||||||
// you can adjust the limit. Yes, it's more work, but you're doing
|
// Message::ParseFromCodedStream() instead. Yes, it's more work, but
|
||||||
// something unusual.
|
// you're doing something unusual.
|
||||||
void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold);
|
void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold);
|
||||||
|
|
||||||
// The Total Bytes Limit minus the Current Position, or -1 if there
|
// The Total Bytes Limit minus the Current Position, or -1 if there
|
||||||
@@ -557,12 +573,6 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// current_limit_. Set using SetTotalBytesLimit().
|
// current_limit_. Set using SetTotalBytesLimit().
|
||||||
int total_bytes_limit_;
|
int total_bytes_limit_;
|
||||||
|
|
||||||
// If positive/0: Limit for bytes read after which a warning due to size
|
|
||||||
// should be logged.
|
|
||||||
// If -1: Printing of warning disabled. Can be set by client.
|
|
||||||
// If -2: Internal: Limit has been reached, print full size when destructing.
|
|
||||||
int total_bytes_warning_threshold_;
|
|
||||||
|
|
||||||
// Current recursion budget, controlled by IncrementRecursionDepth() and
|
// Current recursion budget, controlled by IncrementRecursionDepth() and
|
||||||
// similar. Starts at recursion_limit_ and goes down: if this reaches
|
// similar. Starts at recursion_limit_ and goes down: if this reaches
|
||||||
// -1 we are over budget.
|
// -1 we are over budget.
|
||||||
@@ -570,12 +580,17 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// Recursion depth limit, set by SetRecursionLimit().
|
// Recursion depth limit, set by SetRecursionLimit().
|
||||||
int recursion_limit_;
|
int recursion_limit_;
|
||||||
|
|
||||||
|
bool disable_strict_correctness_enforcement_;
|
||||||
|
|
||||||
// See SetExtensionRegistry().
|
// See SetExtensionRegistry().
|
||||||
const DescriptorPool* extension_pool_;
|
const DescriptorPool* extension_pool_;
|
||||||
MessageFactory* extension_factory_;
|
MessageFactory* extension_factory_;
|
||||||
|
|
||||||
// Private member functions.
|
// Private member functions.
|
||||||
|
|
||||||
|
// Fallback when Skip() goes past the end of the current buffer.
|
||||||
|
bool SkipFallback(int count, int original_buffer_size);
|
||||||
|
|
||||||
// Advance the buffer by a given number of bytes.
|
// Advance the buffer by a given number of bytes.
|
||||||
void Advance(int amount);
|
void Advance(int amount);
|
||||||
|
|
||||||
@@ -612,6 +627,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
int ReadVarintSizeAsIntSlow();
|
int ReadVarintSizeAsIntSlow();
|
||||||
bool ReadLittleEndian32Fallback(uint32* value);
|
bool ReadLittleEndian32Fallback(uint32* value);
|
||||||
bool ReadLittleEndian64Fallback(uint64* value);
|
bool ReadLittleEndian64Fallback(uint64* value);
|
||||||
|
|
||||||
// Fallback/slow methods for reading tags. These do not update last_tag_,
|
// Fallback/slow methods for reading tags. These do not update last_tag_,
|
||||||
// but will set legitimate_message_end_ if we are at the end of the input
|
// but will set legitimate_message_end_ if we are at the end of the input
|
||||||
// stream.
|
// stream.
|
||||||
@@ -622,9 +638,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
|
|||||||
// Return the size of the buffer.
|
// Return the size of the buffer.
|
||||||
int BufferSize() const;
|
int BufferSize() const;
|
||||||
|
|
||||||
static const int kDefaultTotalBytesLimit = 64 << 20; // 64MB
|
static const int kDefaultTotalBytesLimit = INT_MAX;
|
||||||
|
|
||||||
static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB
|
|
||||||
|
|
||||||
static int default_recursion_limit_; // 100 by default.
|
static int default_recursion_limit_; // 100 by default.
|
||||||
};
|
};
|
||||||
@@ -780,8 +794,8 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
|
|||||||
// but GCC by default doesn't want to inline this.
|
// but GCC by default doesn't want to inline this.
|
||||||
void WriteTag(uint32 value);
|
void WriteTag(uint32 value);
|
||||||
// Like WriteTag() but writing directly to the target array.
|
// Like WriteTag() but writing directly to the target array.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteTagToArray(uint32 value,
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
uint8* target);
|
static uint8* WriteTagToArray(uint32 value, uint8* target);
|
||||||
|
|
||||||
// Returns the number of bytes needed to encode the given value as a varint.
|
// Returns the number of bytes needed to encode the given value as a varint.
|
||||||
static size_t VarintSize32(uint32 value);
|
static size_t VarintSize32(uint32 value);
|
||||||
@@ -842,13 +856,17 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
|
|||||||
serialization_deterministic_override_ = value;
|
serialization_deterministic_override_ = value;
|
||||||
}
|
}
|
||||||
// See above. Also, note that users of this CodedOutputStream may need to
|
// See above. Also, note that users of this CodedOutputStream may need to
|
||||||
// call IsSerializationDeterminstic() to serialize in the intended way. This
|
// call IsSerializationDeterministic() to serialize in the intended way. This
|
||||||
// CodedOutputStream cannot enforce a desire for deterministic serialization
|
// CodedOutputStream cannot enforce a desire for deterministic serialization
|
||||||
// by itself.
|
// by itself.
|
||||||
bool IsSerializationDeterminstic() const {
|
bool IsSerializationDeterministic() const {
|
||||||
return serialization_deterministic_is_overridden_ ?
|
return serialization_deterministic_is_overridden_ ?
|
||||||
serialization_deterministic_override_ :
|
serialization_deterministic_override_ :
|
||||||
default_serialization_deterministic_;
|
IsDefaultSerializationDeterministic();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsDefaultSerializationDeterministic() {
|
||||||
|
return google::protobuf::internal::NoBarrier_Load(&default_serialization_deterministic_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -863,7 +881,9 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
|
|||||||
// See SetSerializationDeterministic() regarding these three fields.
|
// See SetSerializationDeterministic() regarding these three fields.
|
||||||
bool serialization_deterministic_is_overridden_;
|
bool serialization_deterministic_is_overridden_;
|
||||||
bool serialization_deterministic_override_;
|
bool serialization_deterministic_override_;
|
||||||
static bool default_serialization_deterministic_;
|
// Conceptually, default_serialization_deterministic_ is an atomic bool.
|
||||||
|
// TODO(haberman): replace with std::atomic<bool> when we move to C++11.
|
||||||
|
static google::protobuf::internal::AtomicWord default_serialization_deterministic_;
|
||||||
|
|
||||||
// Advance the buffer by a given number of bytes.
|
// Advance the buffer by a given number of bytes.
|
||||||
void Advance(int amount);
|
void Advance(int amount);
|
||||||
@@ -879,22 +899,18 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
|
|||||||
// If this write might cross the end of the buffer, we compose the bytes first
|
// If this write might cross the end of the buffer, we compose the bytes first
|
||||||
// then use WriteRaw().
|
// then use WriteRaw().
|
||||||
void WriteVarint32SlowPath(uint32 value);
|
void WriteVarint32SlowPath(uint32 value);
|
||||||
|
void WriteVarint64SlowPath(uint64 value);
|
||||||
// Always-inlined versions of WriteVarint* functions so that code can be
|
|
||||||
// reused, while still controlling size. For instance, WriteVarint32ToArray()
|
|
||||||
// should not directly call this: since it is inlined itself, doing so
|
|
||||||
// would greatly increase the size of generated code. Instead, it should call
|
|
||||||
// WriteVarint32FallbackToArray. Meanwhile, WriteVarint32() is already
|
|
||||||
// out-of-line, so it should just invoke this directly to avoid any extra
|
|
||||||
// function call overhead.
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline(
|
|
||||||
uint64 value, uint8* target);
|
|
||||||
|
|
||||||
static size_t VarintSize32Fallback(uint32 value);
|
|
||||||
|
|
||||||
// See above. Other projects may use "friend" to allow them to call this.
|
// See above. Other projects may use "friend" to allow them to call this.
|
||||||
|
// After SetDefaultSerializationDeterministic() completes, all protocol
|
||||||
|
// buffer serializations will be deterministic by default. Thread safe.
|
||||||
|
// However, the meaning of "after" is subtle here: to be safe, each thread
|
||||||
|
// that wants deterministic serialization by default needs to call
|
||||||
|
// SetDefaultSerializationDeterministic() or ensure on its own that another
|
||||||
|
// thread has done so.
|
||||||
|
friend void ::google::protobuf::internal::MapTestForceDeterministic();
|
||||||
static void SetDefaultSerializationDeterministic() {
|
static void SetDefaultSerializationDeterministic() {
|
||||||
default_serialization_deterministic_ = true;
|
google::protobuf::internal::NoBarrier_Store(&default_serialization_deterministic_, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -981,8 +997,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
|
|||||||
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
|
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
|
||||||
#if defined(PROTOBUF_LITTLE_ENDIAN)
|
#if defined(PROTOBUF_LITTLE_ENDIAN)
|
||||||
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
||||||
memcpy(value, buffer_, sizeof(*value));
|
buffer_ = ReadLittleEndian32FromArray(buffer_, value);
|
||||||
Advance(sizeof(*value));
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ReadLittleEndian32Fallback(value);
|
return ReadLittleEndian32Fallback(value);
|
||||||
@@ -995,8 +1010,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
|
|||||||
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
|
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
|
||||||
#if defined(PROTOBUF_LITTLE_ENDIAN)
|
#if defined(PROTOBUF_LITTLE_ENDIAN)
|
||||||
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
||||||
memcpy(value, buffer_, sizeof(*value));
|
buffer_ = ReadLittleEndian64FromArray(buffer_, value);
|
||||||
Advance(sizeof(*value));
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ReadLittleEndian64Fallback(value);
|
return ReadLittleEndian64Fallback(value);
|
||||||
@@ -1006,21 +1020,20 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32 CodedInputStream::ReadTag() {
|
inline uint32 CodedInputStream::ReadTagNoLastTag() {
|
||||||
uint32 v = 0;
|
uint32 v = 0;
|
||||||
if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
||||||
v = *buffer_;
|
v = *buffer_;
|
||||||
if (v < 0x80) {
|
if (v < 0x80) {
|
||||||
last_tag_ = v;
|
|
||||||
Advance(1);
|
Advance(1);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_tag_ = ReadTagFallback(v);
|
v = ReadTagFallback(v);
|
||||||
return last_tag_;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
|
inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
|
||||||
uint32 cutoff) {
|
uint32 cutoff) {
|
||||||
// In performance-sensitive code we can expect cutoff to be a compile-time
|
// In performance-sensitive code we can expect cutoff to be a compile-time
|
||||||
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
|
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
|
||||||
@@ -1033,7 +1046,7 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
|
|||||||
first_byte_or_zero = buffer_[0];
|
first_byte_or_zero = buffer_[0];
|
||||||
if (static_cast<int8>(buffer_[0]) > 0) {
|
if (static_cast<int8>(buffer_[0]) > 0) {
|
||||||
const uint32 kMax1ByteVarint = 0x7f;
|
const uint32 kMax1ByteVarint = 0x7f;
|
||||||
uint32 tag = last_tag_ = buffer_[0];
|
uint32 tag = buffer_[0];
|
||||||
Advance(1);
|
Advance(1);
|
||||||
return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
|
return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
|
||||||
}
|
}
|
||||||
@@ -1044,7 +1057,7 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
|
|||||||
GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
|
GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
|
||||||
GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
|
GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
|
||||||
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
|
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
|
||||||
uint32 tag = last_tag_ = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
|
uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
|
||||||
Advance(2);
|
Advance(2);
|
||||||
// It might make sense to test for tag == 0 now, but it is so rare that
|
// It might make sense to test for tag == 0 now, but it is so rare that
|
||||||
// that we don't bother. A varint-encoded 0 should be one byte unless
|
// that we don't bother. A varint-encoded 0 should be one byte unless
|
||||||
@@ -1057,8 +1070,8 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Slow path
|
// Slow path
|
||||||
last_tag_ = ReadTagFallback(first_byte_or_zero);
|
const uint32 tag = ReadTagFallback(first_byte_or_zero);
|
||||||
return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff);
|
return std::make_pair(tag, static_cast<uint32>(tag - 1) < cutoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodedInputStream::LastTagWas(uint32 expected) {
|
inline bool CodedInputStream::LastTagWas(uint32 expected) {
|
||||||
@@ -1153,21 +1166,24 @@ inline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value,
|
|||||||
return target + 1;
|
return target + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) {
|
inline uint8* CodedOutputStream::WriteVarint64ToArray(uint64 value,
|
||||||
if (value < 0) {
|
uint8* target) {
|
||||||
WriteVarint64(static_cast<uint64>(value));
|
while (value >= 0x80) {
|
||||||
} else {
|
*target = static_cast<uint8>(value | 0x80);
|
||||||
WriteVarint32(static_cast<uint32>(value));
|
value >>= 7;
|
||||||
|
++target;
|
||||||
}
|
}
|
||||||
|
*target = static_cast<uint8>(value);
|
||||||
|
return target + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) {
|
||||||
|
WriteVarint64(static_cast<uint64>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray(
|
inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray(
|
||||||
int32 value, uint8* target) {
|
int32 value, uint8* target) {
|
||||||
if (value < 0) {
|
return WriteVarint64ToArray(static_cast<uint64>(value), target);
|
||||||
return WriteVarint64ToArray(static_cast<uint64>(value), target);
|
|
||||||
} else {
|
|
||||||
return WriteVarint32ToArray(static_cast<uint32>(value), target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value,
|
inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value,
|
||||||
@@ -1216,6 +1232,19 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void CodedOutputStream::WriteVarint64(uint64 value) {
|
||||||
|
if (buffer_size_ >= 10) {
|
||||||
|
// Fast path: We have enough bytes left in the buffer to guarantee that
|
||||||
|
// this write won't cross the end, so we can skip the checks.
|
||||||
|
uint8* target = buffer_;
|
||||||
|
uint8* end = WriteVarint64ToArray(value, target);
|
||||||
|
int size = static_cast<int>(end - target);
|
||||||
|
Advance(size);
|
||||||
|
} else {
|
||||||
|
WriteVarint64SlowPath(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void CodedOutputStream::WriteTag(uint32 value) {
|
inline void CodedOutputStream::WriteTag(uint32 value) {
|
||||||
WriteVarint32(value);
|
WriteVarint32(value);
|
||||||
}
|
}
|
||||||
@@ -1226,11 +1255,23 @@ inline uint8* CodedOutputStream::WriteTagToArray(
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline size_t CodedOutputStream::VarintSize32(uint32 value) {
|
inline size_t CodedOutputStream::VarintSize32(uint32 value) {
|
||||||
if (value < (1 << 7)) {
|
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
|
||||||
return 1;
|
// Use an explicit multiplication to implement the divide of
|
||||||
} else {
|
// a number in the 1..31 range.
|
||||||
return VarintSize32Fallback(value);
|
// Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
|
||||||
}
|
// undefined.
|
||||||
|
uint32 log2value = Bits::Log2FloorNonZero(value | 0x1);
|
||||||
|
return static_cast<size_t>((log2value * 9 + 73) / 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CodedOutputStream::VarintSize64(uint64 value) {
|
||||||
|
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
|
||||||
|
// Use an explicit multiplication to implement the divide of
|
||||||
|
// a number in the 1..63 range.
|
||||||
|
// Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
|
||||||
|
// undefined.
|
||||||
|
uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1);
|
||||||
|
return static_cast<size_t>((log2value * 9 + 73) / 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) {
|
inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) {
|
||||||
@@ -1321,9 +1362,9 @@ inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)
|
|||||||
current_limit_(kint32max),
|
current_limit_(kint32max),
|
||||||
buffer_size_after_limit_(0),
|
buffer_size_after_limit_(0),
|
||||||
total_bytes_limit_(kDefaultTotalBytesLimit),
|
total_bytes_limit_(kDefaultTotalBytesLimit),
|
||||||
total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),
|
|
||||||
recursion_budget_(default_recursion_limit_),
|
recursion_budget_(default_recursion_limit_),
|
||||||
recursion_limit_(default_recursion_limit_),
|
recursion_limit_(default_recursion_limit_),
|
||||||
|
disable_strict_correctness_enforcement_(true),
|
||||||
extension_pool_(NULL),
|
extension_pool_(NULL),
|
||||||
extension_factory_(NULL) {
|
extension_factory_(NULL) {
|
||||||
// Eagerly Refresh() so buffer space is immediately available.
|
// Eagerly Refresh() so buffer space is immediately available.
|
||||||
@@ -1342,9 +1383,9 @@ inline CodedInputStream::CodedInputStream(const uint8* buffer, int size)
|
|||||||
current_limit_(size),
|
current_limit_(size),
|
||||||
buffer_size_after_limit_(0),
|
buffer_size_after_limit_(0),
|
||||||
total_bytes_limit_(kDefaultTotalBytesLimit),
|
total_bytes_limit_(kDefaultTotalBytesLimit),
|
||||||
total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),
|
|
||||||
recursion_budget_(default_recursion_limit_),
|
recursion_budget_(default_recursion_limit_),
|
||||||
recursion_limit_(default_recursion_limit_),
|
recursion_limit_(default_recursion_limit_),
|
||||||
|
disable_strict_correctness_enforcement_(true),
|
||||||
extension_pool_(NULL),
|
extension_pool_(NULL),
|
||||||
extension_factory_(NULL) {
|
extension_factory_(NULL) {
|
||||||
// Note that setting current_limit_ == size is important to prevent some
|
// Note that setting current_limit_ == size is important to prevent some
|
||||||
@@ -1355,11 +1396,25 @@ inline bool CodedInputStream::IsFlat() const {
|
|||||||
return input_ == NULL;
|
return input_ == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool CodedInputStream::Skip(int count) {
|
||||||
|
if (count < 0) return false; // security: count is often user-supplied
|
||||||
|
|
||||||
|
const int original_buffer_size = BufferSize();
|
||||||
|
|
||||||
|
if (count <= original_buffer_size) {
|
||||||
|
// Just skipping within the current buffer. Easy.
|
||||||
|
Advance(count);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SkipFallback(count, original_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|
||||||
#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
||||||
#pragma runtime_checks("c", restore)
|
#pragma runtime_checks("c", restore)
|
||||||
#endif // _MSC_VER && !defined(__INTEL_COMPILER)
|
#endif // _MSC_VER && !defined(__INTEL_COMPILER)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ void GzipInputStream::BackUp(int count) {
|
|||||||
}
|
}
|
||||||
bool GzipInputStream::Skip(int count) {
|
bool GzipInputStream::Skip(int count) {
|
||||||
const void* data;
|
const void* data;
|
||||||
int size;
|
int size = 0;
|
||||||
bool ok = Next(&data, &size);
|
bool ok = Next(&data, &size);
|
||||||
while (ok && (size < count)) {
|
while (ok && (size < count)) {
|
||||||
count -= size;
|
count -= size;
|
||||||
|
|||||||
+46
-20
@@ -70,8 +70,8 @@ Printer::~Printer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Printer::GetSubstitutionRange(const char* varname,
|
bool Printer::GetSubstitutionRange(const char* varname,
|
||||||
pair<size_t, size_t>* range) {
|
std::pair<size_t, size_t>* range) {
|
||||||
map<string, pair<size_t, size_t> >::const_iterator iter =
|
std::map<string, std::pair<size_t, size_t> >::const_iterator iter =
|
||||||
substitutions_.find(varname);
|
substitutions_.find(varname);
|
||||||
if (iter == substitutions_.end()) {
|
if (iter == substitutions_.end()) {
|
||||||
GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname;
|
GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname;
|
||||||
@@ -87,12 +87,12 @@ bool Printer::GetSubstitutionRange(const char* varname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Printer::Annotate(const char* begin_varname, const char* end_varname,
|
void Printer::Annotate(const char* begin_varname, const char* end_varname,
|
||||||
const string& file_path, const vector<int>& path) {
|
const string& file_path, const std::vector<int>& path) {
|
||||||
if (annotation_collector_ == NULL) {
|
if (annotation_collector_ == NULL) {
|
||||||
// Can't generate signatures with this Printer.
|
// Can't generate signatures with this Printer.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pair<size_t, size_t> begin, end;
|
std::pair<size_t, size_t> begin, end;
|
||||||
if (!GetSubstitutionRange(begin_varname, &begin) ||
|
if (!GetSubstitutionRange(begin_varname, &begin) ||
|
||||||
!GetSubstitutionRange(end_varname, &end)) {
|
!GetSubstitutionRange(end_varname, &end)) {
|
||||||
return;
|
return;
|
||||||
@@ -106,10 +106,12 @@ void Printer::Annotate(const char* begin_varname, const char* end_varname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Printer::Print(const map<string, string>& variables, const char* text) {
|
void Printer::Print(const std::map<string, string>& variables,
|
||||||
|
const char* text) {
|
||||||
int size = strlen(text);
|
int size = strlen(text);
|
||||||
int pos = 0; // The number of bytes we've written so far.
|
int pos = 0; // The number of bytes we've written so far.
|
||||||
substitutions_.clear();
|
substitutions_.clear();
|
||||||
|
line_start_variables_.clear();
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
if (text[i] == '\n') {
|
if (text[i] == '\n') {
|
||||||
@@ -121,6 +123,7 @@ void Printer::Print(const map<string, string>& variables, const char* text) {
|
|||||||
// Setting this true will cause the next WriteRaw() to insert an indent
|
// Setting this true will cause the next WriteRaw() to insert an indent
|
||||||
// first.
|
// first.
|
||||||
at_start_of_line_ = true;
|
at_start_of_line_ = true;
|
||||||
|
line_start_variables_.clear();
|
||||||
|
|
||||||
} else if (text[i] == variable_delimiter_) {
|
} else if (text[i] == variable_delimiter_) {
|
||||||
// Saw the start of a variable name.
|
// Saw the start of a variable name.
|
||||||
@@ -143,15 +146,19 @@ void Printer::Print(const map<string, string>& variables, const char* text) {
|
|||||||
WriteRaw(&variable_delimiter_, 1);
|
WriteRaw(&variable_delimiter_, 1);
|
||||||
} else {
|
} else {
|
||||||
// Replace with the variable's value.
|
// Replace with the variable's value.
|
||||||
map<string, string>::const_iterator iter = variables.find(varname);
|
std::map<string, string>::const_iterator iter = variables.find(varname);
|
||||||
if (iter == variables.end()) {
|
if (iter == variables.end()) {
|
||||||
GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname;
|
GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname;
|
||||||
} else {
|
} else {
|
||||||
size_t begin = offset_;
|
if (at_start_of_line_ && iter->second.empty()) {
|
||||||
|
line_start_variables_.push_back(varname);
|
||||||
|
}
|
||||||
WriteRaw(iter->second.data(), iter->second.size());
|
WriteRaw(iter->second.data(), iter->second.size());
|
||||||
pair<map<string, pair<size_t, size_t> >::iterator, bool> inserted =
|
std::pair<std::map<string, std::pair<size_t, size_t> >::iterator,
|
||||||
substitutions_.insert(
|
bool>
|
||||||
std::make_pair(varname, std::make_pair(begin, offset_)));
|
inserted = substitutions_.insert(std::make_pair(
|
||||||
|
varname,
|
||||||
|
std::make_pair(offset_ - iter->second.size(), offset_)));
|
||||||
if (!inserted.second) {
|
if (!inserted.second) {
|
||||||
// This variable was used multiple times. Make its span have
|
// This variable was used multiple times. Make its span have
|
||||||
// negative length so we can detect it if it gets used in an
|
// negative length so we can detect it if it gets used in an
|
||||||
@@ -172,13 +179,13 @@ void Printer::Print(const map<string, string>& variables, const char* text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Printer::Print(const char* text) {
|
void Printer::Print(const char* text) {
|
||||||
static map<string, string> empty;
|
static std::map<string, string> empty;
|
||||||
Print(empty, text);
|
Print(empty, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Printer::Print(const char* text,
|
void Printer::Print(const char* text,
|
||||||
const char* variable, const string& value) {
|
const char* variable, const string& value) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable] = value;
|
vars[variable] = value;
|
||||||
Print(vars, text);
|
Print(vars, text);
|
||||||
}
|
}
|
||||||
@@ -186,7 +193,7 @@ void Printer::Print(const char* text,
|
|||||||
void Printer::Print(const char* text,
|
void Printer::Print(const char* text,
|
||||||
const char* variable1, const string& value1,
|
const char* variable1, const string& value1,
|
||||||
const char* variable2, const string& value2) {
|
const char* variable2, const string& value2) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
Print(vars, text);
|
Print(vars, text);
|
||||||
@@ -196,7 +203,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable1, const string& value1,
|
const char* variable1, const string& value1,
|
||||||
const char* variable2, const string& value2,
|
const char* variable2, const string& value2,
|
||||||
const char* variable3, const string& value3) {
|
const char* variable3, const string& value3) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -208,7 +215,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable2, const string& value2,
|
const char* variable2, const string& value2,
|
||||||
const char* variable3, const string& value3,
|
const char* variable3, const string& value3,
|
||||||
const char* variable4, const string& value4) {
|
const char* variable4, const string& value4) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -222,7 +229,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable3, const string& value3,
|
const char* variable3, const string& value3,
|
||||||
const char* variable4, const string& value4,
|
const char* variable4, const string& value4,
|
||||||
const char* variable5, const string& value5) {
|
const char* variable5, const string& value5) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -238,7 +245,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable4, const string& value4,
|
const char* variable4, const string& value4,
|
||||||
const char* variable5, const string& value5,
|
const char* variable5, const string& value5,
|
||||||
const char* variable6, const string& value6) {
|
const char* variable6, const string& value6) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -256,7 +263,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable5, const string& value5,
|
const char* variable5, const string& value5,
|
||||||
const char* variable6, const string& value6,
|
const char* variable6, const string& value6,
|
||||||
const char* variable7, const string& value7) {
|
const char* variable7, const string& value7) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -276,7 +283,7 @@ void Printer::Print(const char* text,
|
|||||||
const char* variable6, const string& value6,
|
const char* variable6, const string& value6,
|
||||||
const char* variable7, const string& value7,
|
const char* variable7, const string& value7,
|
||||||
const char* variable8, const string& value8) {
|
const char* variable8, const string& value8) {
|
||||||
map<string, string> vars;
|
std::map<string, string> vars;
|
||||||
vars[variable1] = value1;
|
vars[variable1] = value1;
|
||||||
vars[variable2] = value2;
|
vars[variable2] = value2;
|
||||||
vars[variable3] = value3;
|
vars[variable3] = value3;
|
||||||
@@ -317,10 +324,29 @@ void Printer::WriteRaw(const char* data, int size) {
|
|||||||
if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) {
|
if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) {
|
||||||
// Insert an indent.
|
// Insert an indent.
|
||||||
at_start_of_line_ = false;
|
at_start_of_line_ = false;
|
||||||
WriteRaw(indent_.data(), indent_.size());
|
CopyToBuffer(indent_.data(), indent_.size());
|
||||||
if (failed_) return;
|
if (failed_) return;
|
||||||
|
// Fix up empty variables (e.g., "{") that should be annotated as
|
||||||
|
// coming after the indent.
|
||||||
|
for (std::vector<string>::iterator i = line_start_variables_.begin();
|
||||||
|
i != line_start_variables_.end(); ++i) {
|
||||||
|
substitutions_[*i].first += indent_.size();
|
||||||
|
substitutions_[*i].second += indent_.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're going to write any data, clear line_start_variables_, since
|
||||||
|
// we've either updated them in the block above or they no longer refer to
|
||||||
|
// the current line.
|
||||||
|
line_start_variables_.clear();
|
||||||
|
|
||||||
|
CopyToBuffer(data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Printer::CopyToBuffer(const char* data, int size) {
|
||||||
|
if (failed_) return;
|
||||||
|
if (size == 0) return;
|
||||||
|
|
||||||
while (size > buffer_size_) {
|
while (size > buffer_size_) {
|
||||||
// Data exceeds space in the buffer. Copy what we can and request a
|
// Data exceeds space in the buffer. Copy what we can and request a
|
||||||
// new buffer.
|
// new buffer.
|
||||||
|
|||||||
+19
-9
@@ -55,7 +55,7 @@ class LIBPROTOBUF_EXPORT AnnotationCollector {
|
|||||||
// before end_offset are associated with the SourceCodeInfo-style path.
|
// before end_offset are associated with the SourceCodeInfo-style path.
|
||||||
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
|
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
|
||||||
const string& file_path,
|
const string& file_path,
|
||||||
const vector<int>& path) = 0;
|
const std::vector<int>& path) = 0;
|
||||||
|
|
||||||
virtual ~AnnotationCollector() {}
|
virtual ~AnnotationCollector() {}
|
||||||
};
|
};
|
||||||
@@ -73,7 +73,8 @@ class AnnotationProtoCollector : public AnnotationCollector {
|
|||||||
|
|
||||||
// Override for AnnotationCollector::AddAnnotation.
|
// Override for AnnotationCollector::AddAnnotation.
|
||||||
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
|
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
|
||||||
const string& file_path, const vector<int>& path) {
|
const string& file_path,
|
||||||
|
const std::vector<int>& path) {
|
||||||
typename AnnotationProto::Annotation* annotation =
|
typename AnnotationProto::Annotation* annotation =
|
||||||
annotation_proto_->add_annotation();
|
annotation_proto_->add_annotation();
|
||||||
for (int i = 0; i < path.size(); ++i) {
|
for (int i = 0; i < path.size(); ++i) {
|
||||||
@@ -156,7 +157,7 @@ class AnnotationProtoCollector : public AnnotationCollector {
|
|||||||
// vars["function"] = "call";
|
// vars["function"] = "call";
|
||||||
// vars["mark"] = "";
|
// vars["mark"] = "";
|
||||||
// printer.Print(vars, "$function$($foo$,$foo$)$mark$");
|
// printer.Print(vars, "$function$($foo$,$foo$)$mark$");
|
||||||
// printer.Annotate("function", "rmark", call_);
|
// printer.Annotate("function", "mark", call_);
|
||||||
//
|
//
|
||||||
// This code associates the span covering "call(bar,bar)" in the output with the
|
// This code associates the span covering "call(bar,bar)" in the output with the
|
||||||
// call_ descriptor.
|
// call_ descriptor.
|
||||||
@@ -195,7 +196,7 @@ class LIBPROTOBUF_EXPORT Printer {
|
|||||||
// of building the location path.
|
// of building the location path.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vector<int> path;
|
std::vector<int> path;
|
||||||
descriptor->GetLocationPath(&path);
|
descriptor->GetLocationPath(&path);
|
||||||
Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
|
Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
|
||||||
}
|
}
|
||||||
@@ -216,7 +217,7 @@ class LIBPROTOBUF_EXPORT Printer {
|
|||||||
// Annotations aren't turned on for this Printer.
|
// Annotations aren't turned on for this Printer.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vector<int> empty_path;
|
std::vector<int> empty_path;
|
||||||
Annotate(begin_varname, end_varname, file_name, empty_path);
|
Annotate(begin_varname, end_varname, file_name, empty_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ class LIBPROTOBUF_EXPORT Printer {
|
|||||||
// substituted are identified by their names surrounded by delimiter
|
// substituted are identified by their names surrounded by delimiter
|
||||||
// characters (as given to the constructor). The variable bindings are
|
// characters (as given to the constructor). The variable bindings are
|
||||||
// defined by the given map.
|
// defined by the given map.
|
||||||
void Print(const map<string, string>& variables, const char* text);
|
void Print(const std::map<string, string>& variables, const char* text);
|
||||||
|
|
||||||
// Like the first Print(), except the substitutions are given as parameters.
|
// Like the first Print(), except the substitutions are given as parameters.
|
||||||
void Print(const char* text);
|
void Print(const char* text);
|
||||||
@@ -308,7 +309,10 @@ class LIBPROTOBUF_EXPORT Printer {
|
|||||||
// substituted for end_varname. Note that begin_varname and end_varname
|
// substituted for end_varname. Note that begin_varname and end_varname
|
||||||
// may refer to the same variable.
|
// may refer to the same variable.
|
||||||
void Annotate(const char* begin_varname, const char* end_varname,
|
void Annotate(const char* begin_varname, const char* end_varname,
|
||||||
const string& file_path, const vector<int>& path);
|
const string& file_path, const std::vector<int>& path);
|
||||||
|
|
||||||
|
// Copy size worth of bytes from data to buffer_.
|
||||||
|
void CopyToBuffer(const char* data, int size);
|
||||||
|
|
||||||
const char variable_delimiter_;
|
const char variable_delimiter_;
|
||||||
|
|
||||||
@@ -331,13 +335,19 @@ class LIBPROTOBUF_EXPORT Printer {
|
|||||||
// start offset is the beginning of the substitution; the end offset is the
|
// start offset is the beginning of the substitution; the end offset is the
|
||||||
// last byte of the substitution plus one (such that (end - start) is the
|
// last byte of the substitution plus one (such that (end - start) is the
|
||||||
// length of the substituted string).
|
// length of the substituted string).
|
||||||
map<string, pair<size_t, size_t> > substitutions_;
|
std::map<string, std::pair<size_t, size_t> > substitutions_;
|
||||||
|
|
||||||
|
// Keeps track of the keys in substitutions_ that need to be updated when
|
||||||
|
// indents are inserted. These are keys that refer to the beginning of the
|
||||||
|
// current line.
|
||||||
|
std::vector<string> line_start_variables_;
|
||||||
|
|
||||||
// Returns true and sets range to the substitution range in the output for
|
// Returns true and sets range to the substitution range in the output for
|
||||||
// varname if varname was used once in the last call to Print. If varname
|
// varname if varname was used once in the last call to Print. If varname
|
||||||
// was not used, or if it was used multiple times, returns false (and
|
// was not used, or if it was used multiple times, returns false (and
|
||||||
// fails a debug assertion).
|
// fails a debug assertion).
|
||||||
bool GetSubstitutionRange(const char* varname, pair<size_t, size_t>* range);
|
bool GetSubstitutionRange(const char* varname,
|
||||||
|
std::pair<size_t, size_t>* range);
|
||||||
|
|
||||||
// If non-null, annotation_collector_ is used to store annotations about
|
// If non-null, annotation_collector_ is used to store annotations about
|
||||||
// generated code.
|
// generated code.
|
||||||
|
|||||||
+3
-3
@@ -665,7 +665,7 @@ namespace {
|
|||||||
class CommentCollector {
|
class CommentCollector {
|
||||||
public:
|
public:
|
||||||
CommentCollector(string* prev_trailing_comments,
|
CommentCollector(string* prev_trailing_comments,
|
||||||
vector<string>* detached_comments,
|
std::vector<string>* detached_comments,
|
||||||
string* next_leading_comments)
|
string* next_leading_comments)
|
||||||
: prev_trailing_comments_(prev_trailing_comments),
|
: prev_trailing_comments_(prev_trailing_comments),
|
||||||
detached_comments_(detached_comments),
|
detached_comments_(detached_comments),
|
||||||
@@ -737,7 +737,7 @@ class CommentCollector {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
string* prev_trailing_comments_;
|
string* prev_trailing_comments_;
|
||||||
vector<string>* detached_comments_;
|
std::vector<string>* detached_comments_;
|
||||||
string* next_leading_comments_;
|
string* next_leading_comments_;
|
||||||
|
|
||||||
string comment_buffer_;
|
string comment_buffer_;
|
||||||
@@ -757,7 +757,7 @@ class CommentCollector {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool Tokenizer::NextWithComments(string* prev_trailing_comments,
|
bool Tokenizer::NextWithComments(string* prev_trailing_comments,
|
||||||
vector<string>* detached_comments,
|
std::vector<string>* detached_comments,
|
||||||
string* next_leading_comments) {
|
string* next_leading_comments) {
|
||||||
CommentCollector collector(prev_trailing_comments, detached_comments,
|
CommentCollector collector(prev_trailing_comments, detached_comments,
|
||||||
next_leading_comments);
|
next_leading_comments);
|
||||||
|
|||||||
+1
-1
@@ -191,7 +191,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
|
|||||||
// * grault. */
|
// * grault. */
|
||||||
// optional int32 grault = 6;
|
// optional int32 grault = 6;
|
||||||
bool NextWithComments(string* prev_trailing_comments,
|
bool NextWithComments(string* prev_trailing_comments,
|
||||||
vector<string>* detached_comments,
|
std::vector<string>* detached_comments,
|
||||||
string* next_leading_comments);
|
string* next_leading_comments);
|
||||||
|
|
||||||
// Parse helpers ---------------------------------------------------
|
// Parse helpers ---------------------------------------------------
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
|
||||||
ZeroCopyInputStream::~ZeroCopyInputStream() {}
|
|
||||||
ZeroCopyOutputStream::~ZeroCopyOutputStream() {}
|
|
||||||
|
|
||||||
|
|
||||||
bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */,
|
bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */,
|
||||||
int /* size */) {
|
int /* size */) {
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ class ZeroCopyOutputStream;
|
|||||||
// copying.
|
// copying.
|
||||||
class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
|
class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
|
||||||
public:
|
public:
|
||||||
inline ZeroCopyInputStream() {}
|
ZeroCopyInputStream() {}
|
||||||
virtual ~ZeroCopyInputStream();
|
virtual ~ZeroCopyInputStream() {}
|
||||||
|
|
||||||
// Obtains a chunk of data from the stream.
|
// Obtains a chunk of data from the stream.
|
||||||
//
|
//
|
||||||
@@ -180,8 +180,8 @@ class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
|
|||||||
// copying.
|
// copying.
|
||||||
class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
|
class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
|
||||||
public:
|
public:
|
||||||
inline ZeroCopyOutputStream() {}
|
ZeroCopyOutputStream() {}
|
||||||
virtual ~ZeroCopyOutputStream();
|
virtual ~ZeroCopyOutputStream() {}
|
||||||
|
|
||||||
// Obtains a buffer into which data can be written. Any data written
|
// Obtains a buffer into which data can be written. Any data written
|
||||||
// into this buffer will eventually (maybe instantly, maybe later on)
|
// into this buffer will eventually (maybe instantly, maybe later on)
|
||||||
|
|||||||
@@ -32,9 +32,7 @@
|
|||||||
// Based on original Protocol Buffers design by
|
// Based on original Protocol Buffers design by
|
||||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -43,11 +41,11 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/logging.h>
|
#include <google/protobuf/stubs/logging.h>
|
||||||
#include <google/protobuf/stubs/stl_util.h>
|
#include <google/protobuf/stubs/stl_util.h>
|
||||||
|
#include <google/protobuf/stubs/io_win32.h>
|
||||||
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
@@ -58,6 +56,13 @@ namespace io {
|
|||||||
// Win32 lseek is broken: If invoked on a non-seekable file descriptor, its
|
// Win32 lseek is broken: If invoked on a non-seekable file descriptor, its
|
||||||
// return value is undefined. We re-define it to always produce an error.
|
// return value is undefined. We re-define it to always produce an error.
|
||||||
#define lseek(fd, offset, origin) ((off_t)-1)
|
#define lseek(fd, offset, origin) ((off_t)-1)
|
||||||
|
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
|
||||||
|
// them like we do below.
|
||||||
|
using google::protobuf::internal::win32::access;
|
||||||
|
using google::protobuf::internal::win32::close;
|
||||||
|
using google::protobuf::internal::win32::open;
|
||||||
|
using google::protobuf::internal::win32::read;
|
||||||
|
using google::protobuf::internal::win32::write;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -81,8 +86,6 @@ FileInputStream::FileInputStream(int file_descriptor, int block_size)
|
|||||||
impl_(©ing_input_, block_size) {
|
impl_(©ing_input_, block_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream::~FileInputStream() {}
|
|
||||||
|
|
||||||
bool FileInputStream::Close() {
|
bool FileInputStream::Close() {
|
||||||
return copying_input_.Close();
|
return copying_input_.Close();
|
||||||
}
|
}
|
||||||
@@ -270,12 +273,8 @@ bool FileOutputStream::CopyingFileOutputStream::Write(
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
IstreamInputStream::IstreamInputStream(istream* input, int block_size)
|
IstreamInputStream::IstreamInputStream(std::istream* input, int block_size)
|
||||||
: copying_input_(input),
|
: copying_input_(input), impl_(©ing_input_, block_size) {}
|
||||||
impl_(©ing_input_, block_size) {
|
|
||||||
}
|
|
||||||
|
|
||||||
IstreamInputStream::~IstreamInputStream() {}
|
|
||||||
|
|
||||||
bool IstreamInputStream::Next(const void** data, int* size) {
|
bool IstreamInputStream::Next(const void** data, int* size) {
|
||||||
return impl_.Next(data, size);
|
return impl_.Next(data, size);
|
||||||
@@ -294,9 +293,8 @@ int64 IstreamInputStream::ByteCount() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream(
|
IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream(
|
||||||
istream* input)
|
std::istream* input)
|
||||||
: input_(input) {
|
: input_(input) {}
|
||||||
}
|
|
||||||
|
|
||||||
IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {}
|
IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {}
|
||||||
|
|
||||||
@@ -312,10 +310,8 @@ int IstreamInputStream::CopyingIstreamInputStream::Read(
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
OstreamOutputStream::OstreamOutputStream(ostream* output, int block_size)
|
OstreamOutputStream::OstreamOutputStream(std::ostream* output, int block_size)
|
||||||
: copying_output_(output),
|
: copying_output_(output), impl_(©ing_output_, block_size) {}
|
||||||
impl_(©ing_output_, block_size) {
|
|
||||||
}
|
|
||||||
|
|
||||||
OstreamOutputStream::~OstreamOutputStream() {
|
OstreamOutputStream::~OstreamOutputStream() {
|
||||||
impl_.Flush();
|
impl_.Flush();
|
||||||
@@ -334,9 +330,8 @@ int64 OstreamOutputStream::ByteCount() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream(
|
OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream(
|
||||||
ostream* output)
|
std::ostream* output)
|
||||||
: output_(output) {
|
: output_(output) {}
|
||||||
}
|
|
||||||
|
|
||||||
OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() {
|
OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() {
|
||||||
}
|
}
|
||||||
@@ -354,9 +349,6 @@ ConcatenatingInputStream::ConcatenatingInputStream(
|
|||||||
: streams_(streams), stream_count_(count), bytes_retired_(0) {
|
: streams_(streams), stream_count_(count), bytes_retired_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcatenatingInputStream::~ConcatenatingInputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConcatenatingInputStream::Next(const void** data, int* size) {
|
bool ConcatenatingInputStream::Next(const void** data, int* size) {
|
||||||
while (stream_count_ > 0) {
|
while (stream_count_ > 0) {
|
||||||
if (streams_[0]->Next(data, size)) return true;
|
if (streams_[0]->Next(data, size)) return true;
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
|
|||||||
// should be read and returned with each call to Next(). Otherwise,
|
// should be read and returned with each call to Next(). Otherwise,
|
||||||
// a reasonable default is used.
|
// a reasonable default is used.
|
||||||
explicit FileInputStream(int file_descriptor, int block_size = -1);
|
explicit FileInputStream(int file_descriptor, int block_size = -1);
|
||||||
~FileInputStream();
|
|
||||||
|
|
||||||
// Flushes any buffers and closes the underlying file. Returns false if
|
// Flushes any buffers and closes the underlying file. Returns false if
|
||||||
// an error occurs during the process; use GetErrno() to examine the error.
|
// an error occurs during the process; use GetErrno() to examine the error.
|
||||||
@@ -219,7 +218,6 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
|
|||||||
// should be read and returned with each call to Next(). Otherwise,
|
// should be read and returned with each call to Next(). Otherwise,
|
||||||
// a reasonable default is used.
|
// a reasonable default is used.
|
||||||
explicit IstreamInputStream(std::istream* stream, int block_size = -1);
|
explicit IstreamInputStream(std::istream* stream, int block_size = -1);
|
||||||
~IstreamInputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyInputStream ----------------------------------
|
// implements ZeroCopyInputStream ----------------------------------
|
||||||
bool Next(const void** data, int* size);
|
bool Next(const void** data, int* size);
|
||||||
@@ -306,7 +304,6 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
|
|||||||
// All streams passed in as well as the array itself must remain valid
|
// All streams passed in as well as the array itself must remain valid
|
||||||
// until the ConcatenatingInputStream is destroyed.
|
// until the ConcatenatingInputStream is destroyed.
|
||||||
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
|
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
|
||||||
~ConcatenatingInputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyInputStream ----------------------------------
|
// implements ZeroCopyInputStream ----------------------------------
|
||||||
bool Next(const void** data, int* size);
|
bool Next(const void** data, int* size);
|
||||||
|
|||||||
@@ -64,9 +64,6 @@ ArrayInputStream::ArrayInputStream(const void* data, int size,
|
|||||||
last_returned_size_(0) {
|
last_returned_size_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayInputStream::~ArrayInputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArrayInputStream::Next(const void** data, int* size) {
|
bool ArrayInputStream::Next(const void** data, int* size) {
|
||||||
if (position_ < size_) {
|
if (position_ < size_) {
|
||||||
last_returned_size_ = std::min(block_size_, size_ - position_);
|
last_returned_size_ = std::min(block_size_, size_ - position_);
|
||||||
@@ -117,9 +114,6 @@ ArrayOutputStream::ArrayOutputStream(void* data, int size, int block_size)
|
|||||||
last_returned_size_(0) {
|
last_returned_size_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayOutputStream::~ArrayOutputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArrayOutputStream::Next(void** data, int* size) {
|
bool ArrayOutputStream::Next(void** data, int* size) {
|
||||||
if (position_ < size_) {
|
if (position_ < size_) {
|
||||||
last_returned_size_ = std::min(block_size_, size_ - position_);
|
last_returned_size_ = std::min(block_size_, size_ - position_);
|
||||||
@@ -153,9 +147,6 @@ StringOutputStream::StringOutputStream(string* target)
|
|||||||
: target_(target) {
|
: target_(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StringOutputStream::~StringOutputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StringOutputStream::Next(void** data, int* size) {
|
bool StringOutputStream::Next(void** data, int* size) {
|
||||||
GOOGLE_CHECK(target_ != NULL);
|
GOOGLE_CHECK(target_ != NULL);
|
||||||
int old_size = target_->size();
|
int old_size = target_->size();
|
||||||
@@ -205,32 +196,6 @@ void StringOutputStream::SetString(string* target) {
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
LazyStringOutputStream::LazyStringOutputStream(
|
|
||||||
ResultCallback<string*>* callback)
|
|
||||||
: StringOutputStream(NULL),
|
|
||||||
callback_(GOOGLE_CHECK_NOTNULL(callback)),
|
|
||||||
string_is_set_(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyStringOutputStream::~LazyStringOutputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LazyStringOutputStream::Next(void** data, int* size) {
|
|
||||||
if (!string_is_set_) {
|
|
||||||
SetString(callback_->Run());
|
|
||||||
string_is_set_ = true;
|
|
||||||
}
|
|
||||||
return StringOutputStream::Next(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64 LazyStringOutputStream::ByteCount() const {
|
|
||||||
return string_is_set_ ? StringOutputStream::ByteCount() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
CopyingInputStream::~CopyingInputStream() {}
|
|
||||||
|
|
||||||
int CopyingInputStream::Skip(int count) {
|
int CopyingInputStream::Skip(int count) {
|
||||||
char junk[4096];
|
char junk[4096];
|
||||||
int skipped = 0;
|
int skipped = 0;
|
||||||
@@ -350,8 +315,6 @@ void CopyingInputStreamAdaptor::FreeBuffer() {
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
CopyingOutputStream::~CopyingOutputStream() {}
|
|
||||||
|
|
||||||
CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor(
|
CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor(
|
||||||
CopyingOutputStream* copying_stream, int block_size)
|
CopyingOutputStream* copying_stream, int block_size)
|
||||||
: copying_stream_(copying_stream),
|
: copying_stream_(copying_stream),
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
|
|||||||
// useful for testing; in production you would probably never want to set
|
// useful for testing; in production you would probably never want to set
|
||||||
// it.
|
// it.
|
||||||
ArrayInputStream(const void* data, int size, int block_size = -1);
|
ArrayInputStream(const void* data, int size, int block_size = -1);
|
||||||
~ArrayInputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyInputStream ----------------------------------
|
// implements ZeroCopyInputStream ----------------------------------
|
||||||
bool Next(const void** data, int* size);
|
bool Next(const void** data, int* size);
|
||||||
@@ -107,7 +106,6 @@ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
|
|||||||
// useful for testing; in production you would probably never want to set
|
// useful for testing; in production you would probably never want to set
|
||||||
// it.
|
// it.
|
||||||
ArrayOutputStream(void* data, int size, int block_size = -1);
|
ArrayOutputStream(void* data, int size, int block_size = -1);
|
||||||
~ArrayOutputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyOutputStream ---------------------------------
|
// implements ZeroCopyOutputStream ---------------------------------
|
||||||
bool Next(void** data, int* size);
|
bool Next(void** data, int* size);
|
||||||
@@ -141,7 +139,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
|
|||||||
// the first call to Next() will return at least n bytes of buffer
|
// the first call to Next() will return at least n bytes of buffer
|
||||||
// space.
|
// space.
|
||||||
explicit StringOutputStream(string* target);
|
explicit StringOutputStream(string* target);
|
||||||
~StringOutputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyOutputStream ---------------------------------
|
// implements ZeroCopyOutputStream ---------------------------------
|
||||||
bool Next(void** data, int* size);
|
bool Next(void** data, int* size);
|
||||||
@@ -159,27 +156,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
|
|||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
|
||||||
};
|
};
|
||||||
|
|
||||||
// LazyStringOutputStream is a StringOutputStream with lazy acquisition of
|
|
||||||
// the output string from a callback. The string is owned externally, and not
|
|
||||||
// deleted in the stream destructor.
|
|
||||||
class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream {
|
|
||||||
public:
|
|
||||||
// Callback should be permanent (non-self-deleting). Ownership is transferred
|
|
||||||
// to the LazyStringOutputStream.
|
|
||||||
explicit LazyStringOutputStream(ResultCallback<string*>* callback);
|
|
||||||
~LazyStringOutputStream();
|
|
||||||
|
|
||||||
// implements ZeroCopyOutputStream, overriding StringOutputStream -----------
|
|
||||||
bool Next(void** data, int* size);
|
|
||||||
int64 ByteCount() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const google::protobuf::scoped_ptr<ResultCallback<string*> > callback_;
|
|
||||||
bool string_is_set_;
|
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyStringOutputStream);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Note: There is no StringInputStream. Instead, just create an
|
// Note: There is no StringInputStream. Instead, just create an
|
||||||
// ArrayInputStream as follows:
|
// ArrayInputStream as follows:
|
||||||
// ArrayInputStream input(str.data(), str.size());
|
// ArrayInputStream input(str.data(), str.size());
|
||||||
@@ -199,7 +175,7 @@ class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream {
|
|||||||
// in large blocks.
|
// in large blocks.
|
||||||
class LIBPROTOBUF_EXPORT CopyingInputStream {
|
class LIBPROTOBUF_EXPORT CopyingInputStream {
|
||||||
public:
|
public:
|
||||||
virtual ~CopyingInputStream();
|
virtual ~CopyingInputStream() {}
|
||||||
|
|
||||||
// Reads up to "size" bytes into the given buffer. Returns the number of
|
// Reads up to "size" bytes into the given buffer. Returns the number of
|
||||||
// bytes read. Read() waits until at least one byte is available, or
|
// bytes read. Read() waits until at least one byte is available, or
|
||||||
@@ -293,7 +269,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream
|
|||||||
// in large blocks.
|
// in large blocks.
|
||||||
class LIBPROTOBUF_EXPORT CopyingOutputStream {
|
class LIBPROTOBUF_EXPORT CopyingOutputStream {
|
||||||
public:
|
public:
|
||||||
virtual ~CopyingOutputStream();
|
virtual ~CopyingOutputStream() {}
|
||||||
|
|
||||||
// Writes "size" bytes from the given buffer to the output. Returns true
|
// Writes "size" bytes from the given buffer to the output. Returns true
|
||||||
// if successful, false on a write error.
|
// if successful, false on a write error.
|
||||||
@@ -399,7 +375,7 @@ inline std::pair<char*, bool> as_string_data(string* s) {
|
|||||||
#ifdef LANG_CXX11
|
#ifdef LANG_CXX11
|
||||||
return std::make_pair(p, true);
|
return std::make_pair(p, true);
|
||||||
#else
|
#else
|
||||||
return make_pair(p, p != NULL);
|
return std::make_pair(p, p != NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+124
-656
File diff suppressed because it is too large
Load Diff
+41
-211
@@ -43,10 +43,9 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
class Arena;
|
class Arena;
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Key, typename Value,
|
template <typename Derived, typename Key, typename Value,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
|
||||||
class MapField;
|
class MapField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,30 +53,6 @@ class MapField;
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Register all MapEntry default instances so we can delete them in
|
|
||||||
// ShutdownProtobufLibrary().
|
|
||||||
void LIBPROTOBUF_EXPORT RegisterMapEntryDefaultInstance(
|
|
||||||
MessageLite* default_instance);
|
|
||||||
|
|
||||||
// This is the common base class for MapEntry. It is used by MapFieldBase in
|
|
||||||
// reflection api, in which the static type of key and value is unknown.
|
|
||||||
class LIBPROTOBUF_EXPORT MapEntryBase : public Message {
|
|
||||||
public:
|
|
||||||
::google::protobuf::Metadata GetMetadata() const {
|
|
||||||
::google::protobuf::Metadata metadata;
|
|
||||||
metadata.descriptor = descriptor_;
|
|
||||||
metadata.reflection = reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MapEntryBase() : descriptor_(NULL), reflection_(NULL) { }
|
|
||||||
virtual ~MapEntryBase() {}
|
|
||||||
|
|
||||||
const Descriptor* descriptor_;
|
|
||||||
const Reflection* reflection_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// MapEntry is the returned google::protobuf::Message when calling AddMessage of
|
// MapEntry is the returned google::protobuf::Message when calling AddMessage of
|
||||||
// google::protobuf::Reflection. In order to let it work with generated message
|
// google::protobuf::Reflection. In order to let it work with generated message
|
||||||
// reflection, its in-memory type is the same as generated message with the same
|
// reflection, its in-memory type is the same as generated message with the same
|
||||||
@@ -105,202 +80,57 @@ class LIBPROTOBUF_EXPORT MapEntryBase : public Message {
|
|||||||
// while we need to explicitly specify the cpp type if proto type is
|
// while we need to explicitly specify the cpp type if proto type is
|
||||||
// TYPE_MESSAGE to infer the in-memory type. Moreover, default_enum_value is
|
// TYPE_MESSAGE to infer the in-memory type. Moreover, default_enum_value is
|
||||||
// used to initialize enum field in proto2.
|
// used to initialize enum field in proto2.
|
||||||
template <typename Key, typename Value,
|
template <typename Derived, typename Key, typename Value,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
class MapEntry
|
||||||
class MapEntry : public MapEntryBase {
|
: public MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
|
||||||
// Provide utilities to parse/serialize key/value. Provide utilities to
|
kValueFieldType, default_enum_value> {
|
||||||
// manipulate internal stored type.
|
|
||||||
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
|
||||||
typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;
|
|
||||||
|
|
||||||
// Enum type cannot be used for MapTypeHandler::Read. Define a type
|
|
||||||
// which will replace Enum with int.
|
|
||||||
typedef typename KeyTypeHandler::MapEntryAccessorType KeyMapEntryAccessorType;
|
|
||||||
typedef typename ValueTypeHandler::MapEntryAccessorType
|
|
||||||
ValueMapEntryAccessorType;
|
|
||||||
|
|
||||||
// Abbreviation for MapEntry
|
|
||||||
typedef typename google::protobuf::internal::MapEntry<
|
|
||||||
Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> EntryType;
|
|
||||||
|
|
||||||
// Abbreviation for MapEntryLite
|
|
||||||
typedef typename google::protobuf::internal::MapEntryLite<
|
|
||||||
Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>
|
|
||||||
EntryLiteType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~MapEntry() {
|
MapEntry() : _internal_metadata_(NULL) {}
|
||||||
if (this == default_instance_) {
|
|
||||||
delete reflection_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accessors ======================================================
|
|
||||||
|
|
||||||
virtual inline const KeyMapEntryAccessorType& key() const {
|
|
||||||
return entry_lite_.key();
|
|
||||||
}
|
|
||||||
inline KeyMapEntryAccessorType* mutable_key() {
|
|
||||||
return entry_lite_.mutable_key();
|
|
||||||
}
|
|
||||||
virtual inline const ValueMapEntryAccessorType& value() const {
|
|
||||||
return entry_lite_.value();
|
|
||||||
}
|
|
||||||
inline ValueMapEntryAccessorType* mutable_value() {
|
|
||||||
return entry_lite_.mutable_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
// implements Message =============================================
|
|
||||||
|
|
||||||
bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {
|
|
||||||
return entry_lite_.MergePartialFromCodedStream(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ByteSizeLong() const {
|
|
||||||
return entry_lite_.ByteSizeLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const {
|
|
||||||
entry_lite_.SerializeWithCachedSizes(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
|
|
||||||
::google::protobuf::uint8* output) const {
|
|
||||||
return entry_lite_.InternalSerializeWithCachedSizesToArray(deterministic,
|
|
||||||
output);
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetCachedSize() const {
|
|
||||||
return entry_lite_.GetCachedSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsInitialized() const {
|
|
||||||
return entry_lite_.IsInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
Message* New() const {
|
|
||||||
MapEntry* entry = new MapEntry;
|
|
||||||
entry->descriptor_ = descriptor_;
|
|
||||||
entry->reflection_ = reflection_;
|
|
||||||
entry->set_default_instance(default_instance_);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
Message* New(Arena* arena) const {
|
|
||||||
MapEntry* entry = Arena::CreateMessage<MapEntry>(arena);
|
|
||||||
entry->descriptor_ = descriptor_;
|
|
||||||
entry->reflection_ = reflection_;
|
|
||||||
entry->set_default_instance(default_instance_);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SpaceUsed() const {
|
|
||||||
int size = sizeof(MapEntry);
|
|
||||||
size += entry_lite_.SpaceUsed();
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyFrom(const ::google::protobuf::Message& from) {
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MergeFrom(const ::google::protobuf::Message& from) {
|
|
||||||
GOOGLE_CHECK_NE(&from, this);
|
|
||||||
const MapEntry* source = dynamic_cast_if_available<const MapEntry*>(&from);
|
|
||||||
if (source == NULL) {
|
|
||||||
ReflectionOps::Merge(from, this);
|
|
||||||
} else {
|
|
||||||
MergeFrom(*source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyFrom(const MapEntry& from) {
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MergeFrom(const MapEntry& from) {
|
|
||||||
entry_lite_.MergeFrom(from.entry_lite_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear() {
|
|
||||||
entry_lite_.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitAsDefaultInstance() {
|
|
||||||
entry_lite_.InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena* GetArena() const {
|
|
||||||
return entry_lite_.GetArena();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create default MapEntry instance for given descriptor. Descriptor has to be
|
|
||||||
// given when creating default MapEntry instance because different map field
|
|
||||||
// may have the same type and MapEntry class. The given descriptor is needed
|
|
||||||
// to distinguish instances of the same MapEntry class.
|
|
||||||
static MapEntry* CreateDefaultInstance(const Descriptor* descriptor) {
|
|
||||||
MapEntry* entry = new MapEntry;
|
|
||||||
const Reflection* reflection = new GeneratedMessageReflection(
|
|
||||||
descriptor, entry, offsets_,
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _unknown_fields_), -1,
|
|
||||||
DescriptorPool::generated_pool(),
|
|
||||||
::google::protobuf::MessageFactory::generated_factory(),
|
|
||||||
sizeof(MapEntry),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_));
|
|
||||||
entry->descriptor_ = descriptor;
|
|
||||||
entry->reflection_ = reflection;
|
|
||||||
entry->set_default_instance(entry);
|
|
||||||
entry->InitAsDefaultInstance();
|
|
||||||
RegisterMapEntryDefaultInstance(entry);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
MapEntry()
|
|
||||||
: _internal_metadata_(NULL), default_instance_(NULL), entry_lite_() {}
|
|
||||||
|
|
||||||
explicit MapEntry(Arena* arena)
|
explicit MapEntry(Arena* arena)
|
||||||
: _internal_metadata_(arena),
|
: MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
|
||||||
default_instance_(NULL),
|
kValueFieldType, default_enum_value>(arena),
|
||||||
entry_lite_(arena) {}
|
_internal_metadata_(arena) {}
|
||||||
|
|
||||||
inline Arena* GetArenaNoVirtual() const {
|
|
||||||
return entry_lite_.GetArenaNoVirtual();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_default_instance(MapEntry* default_instance) {
|
|
||||||
default_instance_ = default_instance;
|
|
||||||
entry_lite_.set_default_instance(&default_instance->entry_lite_);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int offsets_[2];
|
|
||||||
UnknownFieldSet _unknown_fields_;
|
|
||||||
InternalMetadataWithArena _internal_metadata_;
|
|
||||||
MapEntry* default_instance_;
|
|
||||||
EntryLiteType entry_lite_;
|
|
||||||
|
|
||||||
friend class ::google::protobuf::Arena;
|
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
template <typename K, typename V, WireFormatLite::FieldType k_wire_type,
|
|
||||||
WireFormatLite::FieldType, int default_enum>
|
InternalMetadataWithArena _internal_metadata_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class ::google::protobuf::Arena;
|
||||||
|
template <typename C, typename K, typename V,
|
||||||
|
WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType,
|
||||||
|
int default_enum>
|
||||||
friend class internal::MapField;
|
friend class internal::MapField;
|
||||||
friend class internal::GeneratedMessageReflection;
|
friend class internal::GeneratedMessageReflection;
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
|
// Specialization for the full runtime
|
||||||
|
template <typename Derived, typename Key, typename Value,
|
||||||
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int MapEntry<Key, Value, kKeyFieldType, kValueFieldType,
|
struct MapEntryHelper<MapEntry<Derived, Key, Value, kKeyFieldType,
|
||||||
default_enum_value>::offsets_[2] = {
|
kValueFieldType, default_enum_value> >
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.key_),
|
: MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType,
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.value_),
|
kValueFieldType, default_enum_value> > {
|
||||||
|
explicit MapEntryHelper(const MapPair<Key, Value>& map_pair)
|
||||||
|
: MapEntryHelper<MapEntryLite<Derived, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value> >(
|
||||||
|
map_pair) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Derived, typename K, typename V,
|
||||||
|
WireFormatLite::FieldType key, WireFormatLite::FieldType value,
|
||||||
|
int default_enum>
|
||||||
|
struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value, default_enum> > {
|
||||||
|
typedef K Key;
|
||||||
|
typedef V Value;
|
||||||
|
static const WireFormatLite::FieldType kKeyFieldType = key;
|
||||||
|
static const WireFormatLite::FieldType kValueFieldType = value;
|
||||||
|
static const int default_enum_value = default_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|||||||
+217
-119
@@ -32,22 +32,23 @@
|
|||||||
#define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
|
#define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <google/protobuf/arena.h>
|
||||||
|
#include <google/protobuf/map.h>
|
||||||
#include <google/protobuf/map_type_handler.h>
|
#include <google/protobuf/map_type_handler.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
class Arena;
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Key, typename Value,
|
template <typename Derived, typename Key, typename Value,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
|
||||||
class MapEntry;
|
class MapEntry;
|
||||||
template <typename Key, typename Value,
|
template <typename Derived, typename Key, typename Value,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
|
||||||
class MapFieldLite;
|
class MapFieldLite;
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
@@ -87,13 +88,14 @@ struct MoveHelper<false, false, true, T> { // strings and similar
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// MapEntryLite is used to implement parsing and serialization of map for lite
|
// MapEntryImpl is used to implement parsing and serialization of map entries.
|
||||||
// runtime.
|
// It uses Curious Recursive Template Pattern (CRTP) to provide the type of
|
||||||
template <typename Key, typename Value,
|
// the eventual code to the template code.
|
||||||
|
template <typename Derived, typename Base, typename Key, typename Value,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
class MapEntryImpl : public Base {
|
||||||
class MapEntryLite : public MessageLite {
|
protected:
|
||||||
// Provide utilities to parse/serialize key/value. Provide utilities to
|
// Provide utilities to parse/serialize key/value. Provide utilities to
|
||||||
// manipulate internal stored type.
|
// manipulate internal stored type.
|
||||||
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
||||||
@@ -122,12 +124,33 @@ class MapEntryLite : public MessageLite {
|
|||||||
static const size_t kTagSize = 1;
|
static const size_t kTagSize = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~MapEntryLite() {
|
// Work-around for a compiler bug (see repeated_field.h).
|
||||||
if (this != default_instance_) {
|
typedef void MapEntryHasMergeTypeTrait;
|
||||||
if (GetArenaNoVirtual() != NULL) return;
|
typedef Derived EntryType;
|
||||||
KeyTypeHandler::DeleteNoArena(key_);
|
typedef Key EntryKeyType;
|
||||||
ValueTypeHandler::DeleteNoArena(value_);
|
typedef Value EntryValueType;
|
||||||
}
|
static const WireFormatLite::FieldType kEntryKeyFieldType = kKeyFieldType;
|
||||||
|
static const WireFormatLite::FieldType kEntryValueFieldType = kValueFieldType;
|
||||||
|
static const int kEntryDefaultEnumValue = default_enum_value;
|
||||||
|
|
||||||
|
MapEntryImpl() : arena_(NULL) {
|
||||||
|
KeyTypeHandler::Initialize(&key_, NULL);
|
||||||
|
ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value,
|
||||||
|
NULL);
|
||||||
|
_has_bits_[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit MapEntryImpl(Arena* arena) : arena_(arena) {
|
||||||
|
KeyTypeHandler::Initialize(&key_, arena);
|
||||||
|
ValueTypeHandler::InitializeMaybeByDefaultEnum(&value_, default_enum_value,
|
||||||
|
arena);
|
||||||
|
_has_bits_[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
~MapEntryImpl() {
|
||||||
|
if (GetArenaNoVirtual() != NULL) return;
|
||||||
|
KeyTypeHandler::DeleteNoArena(key_);
|
||||||
|
ValueTypeHandler::DeleteNoArena(value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessors ======================================================
|
// accessors ======================================================
|
||||||
@@ -136,9 +159,8 @@ class MapEntryLite : public MessageLite {
|
|||||||
return KeyTypeHandler::GetExternalReference(key_);
|
return KeyTypeHandler::GetExternalReference(key_);
|
||||||
}
|
}
|
||||||
virtual inline const ValueMapEntryAccessorType& value() const {
|
virtual inline const ValueMapEntryAccessorType& value() const {
|
||||||
GOOGLE_CHECK(default_instance_ != NULL);
|
return ValueTypeHandler::DefaultIfNotInitialized(
|
||||||
return ValueTypeHandler::DefaultIfNotInitialized(value_,
|
value_, Derived::internal_default_instance()->value_);
|
||||||
default_instance_->value_);
|
|
||||||
}
|
}
|
||||||
inline KeyMapEntryAccessorType* mutable_key() {
|
inline KeyMapEntryAccessorType* mutable_key() {
|
||||||
set_has_key();
|
set_has_key();
|
||||||
@@ -151,12 +173,12 @@ class MapEntryLite : public MessageLite {
|
|||||||
|
|
||||||
// implements MessageLite =========================================
|
// implements MessageLite =========================================
|
||||||
|
|
||||||
// MapEntryLite is for implementation only and this function isn't called
|
// MapEntryImpl is for implementation only and this function isn't called
|
||||||
// anywhere. Just provide a fake implementation here for MessageLite.
|
// anywhere. Just provide a fake implementation here for MessageLite.
|
||||||
string GetTypeName() const { return ""; }
|
string GetTypeName() const { return ""; }
|
||||||
|
|
||||||
void CheckTypeAndMergeFrom(const MessageLite& other) {
|
void CheckTypeAndMergeFrom(const MessageLite& other) {
|
||||||
MergeFrom(*::google::protobuf::down_cast<const MapEntryLite*>(&other));
|
MergeFromInternal(*::google::protobuf::down_cast<const Derived*>(&other));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {
|
bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {
|
||||||
@@ -171,7 +193,7 @@ class MapEntryLite : public MessageLite {
|
|||||||
// need to care whether the value is unknown enum;
|
// need to care whether the value is unknown enum;
|
||||||
// 4) missing key/value: missed key/value will have default value. caller
|
// 4) missing key/value: missed key/value will have default value. caller
|
||||||
// should take this entry as if key/value is set to default value.
|
// should take this entry as if key/value is set to default value.
|
||||||
tag = input->ReadTag();
|
tag = input->ReadTagNoLastTag();
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case kKeyTag:
|
case kKeyTag:
|
||||||
if (!KeyTypeHandler::Read(input, mutable_key())) {
|
if (!KeyTypeHandler::Read(input, mutable_key())) {
|
||||||
@@ -203,8 +225,10 @@ class MapEntryLite : public MessageLite {
|
|||||||
|
|
||||||
size_t ByteSizeLong() const {
|
size_t ByteSizeLong() const {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
size += has_key() ? kTagSize + KeyTypeHandler::ByteSize(key()) : 0;
|
size += has_key() ?
|
||||||
size += has_value() ? kTagSize + ValueTypeHandler::ByteSize(value()) : 0;
|
kTagSize + static_cast<size_t>(KeyTypeHandler::ByteSize(key())) : 0;
|
||||||
|
size += has_value() ?
|
||||||
|
kTagSize + static_cast<size_t>(ValueTypeHandler::ByteSize(value())) : 0;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,44 +245,43 @@ class MapEntryLite : public MessageLite {
|
|||||||
deterministic, output);
|
deterministic, output);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
// Don't override SerializeWithCachedSizesToArray. Use MessageLite's.
|
||||||
}
|
|
||||||
|
|
||||||
int GetCachedSize() const {
|
int GetCachedSize() const {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
size += has_key()
|
size += has_key()
|
||||||
? kTagSize + KeyTypeHandler::GetCachedSize(key())
|
? static_cast<int>(kTagSize) + KeyTypeHandler::GetCachedSize(key())
|
||||||
: 0;
|
: 0;
|
||||||
size += has_value()
|
size += has_value()
|
||||||
? kTagSize + ValueTypeHandler::GetCachedSize(
|
? static_cast<int>(kTagSize) + ValueTypeHandler::GetCachedSize(value())
|
||||||
value())
|
|
||||||
: 0;
|
: 0;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInitialized() const { return ValueTypeHandler::IsInitialized(value_); }
|
bool IsInitialized() const { return ValueTypeHandler::IsInitialized(value_); }
|
||||||
|
|
||||||
MessageLite* New() const {
|
Base* New() const {
|
||||||
MapEntryLite* entry = new MapEntryLite;
|
Derived* entry = new Derived;
|
||||||
entry->default_instance_ = default_instance_;
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLite* New(Arena* arena) const {
|
Base* New(Arena* arena) const {
|
||||||
MapEntryLite* entry = Arena::CreateMessage<MapEntryLite>(arena);
|
Derived* entry = Arena::CreateMessage<Derived>(arena);
|
||||||
entry->default_instance_ = default_instance_;
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpaceUsed() const {
|
size_t SpaceUsedLong() const {
|
||||||
int size = sizeof(MapEntryLite);
|
size_t size = sizeof(Derived);
|
||||||
size += KeyTypeHandler::SpaceUsedInMapEntry(key_);
|
size += KeyTypeHandler::SpaceUsedInMapEntryLong(key_);
|
||||||
size += ValueTypeHandler::SpaceUsedInMapEntry(value_);
|
size += ValueTypeHandler::SpaceUsedInMapEntryLong(value_);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeFrom(const MapEntryLite& from) {
|
protected:
|
||||||
|
// We can't declare this function directly here as it would hide the other
|
||||||
|
// overload (const Message&).
|
||||||
|
void MergeFromInternal(const MapEntryImpl& from) {
|
||||||
if (from._has_bits_[0]) {
|
if (from._has_bits_[0]) {
|
||||||
if (from.has_key()) {
|
if (from.has_key()) {
|
||||||
KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual());
|
KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual());
|
||||||
@@ -273,6 +296,7 @@ class MapEntryLite : public MessageLite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
void Clear() {
|
void Clear() {
|
||||||
KeyTypeHandler::Clear(&key_, GetArenaNoVirtual());
|
KeyTypeHandler::Clear(&key_, GetArenaNoVirtual());
|
||||||
ValueTypeHandler::ClearMaybeByDefaultEnum(
|
ValueTypeHandler::ClearMaybeByDefaultEnum(
|
||||||
@@ -281,33 +305,28 @@ class MapEntryLite : public MessageLite {
|
|||||||
clear_has_value();
|
clear_has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitAsDefaultInstance() {
|
static void InitAsDefaultInstance() {
|
||||||
KeyTypeHandler::AssignDefaultValue(&key_);
|
Derived* d = const_cast<Derived*>(Derived::internal_default_instance());
|
||||||
ValueTypeHandler::AssignDefaultValue(&value_);
|
KeyTypeHandler::AssignDefaultValue(&d->key_);
|
||||||
|
ValueTypeHandler::AssignDefaultValue(&d->value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena* GetArena() const {
|
Arena* GetArena() const {
|
||||||
return GetArenaNoVirtual();
|
return GetArenaNoVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a MapEntryLite for given key and value from google::protobuf::Map in
|
// Create a MapEntryImpl for given key and value from google::protobuf::Map in
|
||||||
// serialization. This function is only called when value is enum. Enum is
|
// serialization. This function is only called when value is enum. Enum is
|
||||||
// treated differently because its type in MapEntry is int and its type in
|
// treated differently because its type in MapEntry is int and its type in
|
||||||
// google::protobuf::Map is enum. We cannot create a reference to int from an enum.
|
// google::protobuf::Map is enum. We cannot create a reference to int from an enum.
|
||||||
static MapEntryLite* EnumWrap(const Key& key, const Value value,
|
static Derived* EnumWrap(const Key& key, const Value value, Arena* arena) {
|
||||||
Arena* arena) {
|
return Arena::CreateMessage<MapEnumEntryWrapper>(arena, key, value);
|
||||||
return Arena::CreateMessage<MapEnumEntryWrapper<
|
|
||||||
Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> >(
|
|
||||||
arena, key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like above, but for all the other types. This avoids value copy to create
|
// Like above, but for all the other types. This avoids value copy to create
|
||||||
// MapEntryLite from google::protobuf::Map in serialization.
|
// MapEntryImpl from google::protobuf::Map in serialization.
|
||||||
static MapEntryLite* Wrap(const Key& key, const Value& value, Arena* arena) {
|
static Derived* Wrap(const Key& key, const Value& value, Arena* arena) {
|
||||||
return Arena::CreateMessage<MapEntryWrapper<Key, Value, kKeyFieldType,
|
return Arena::CreateMessage<MapEntryWrapper>(arena, key, value);
|
||||||
kValueFieldType,
|
|
||||||
default_enum_value> >(
|
|
||||||
arena, key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsing using MergePartialFromCodedStream, above, is not as
|
// Parsing using MergePartialFromCodedStream, above, is not as
|
||||||
@@ -333,7 +352,7 @@ class MapEntryLite : public MessageLite {
|
|||||||
int size;
|
int size;
|
||||||
input->GetDirectBufferPointerInline(&data, &size);
|
input->GetDirectBufferPointerInline(&data, &size);
|
||||||
// We could use memcmp here, but we don't bother. The tag is one byte.
|
// We could use memcmp here, but we don't bother. The tag is one byte.
|
||||||
assert(kTagSize == 1);
|
GOOGLE_COMPILE_ASSERT(kTagSize == 1, tag_size_error);
|
||||||
if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {
|
if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {
|
||||||
typename Map::size_type size = map_->size();
|
typename Map::size_type size = map_->size();
|
||||||
value_ptr_ = &(*map_)[key_];
|
value_ptr_ = &(*map_)[key_];
|
||||||
@@ -357,15 +376,17 @@ class MapEntryLite : public MessageLite {
|
|||||||
|
|
||||||
entry_.reset(mf_->NewEntry());
|
entry_.reset(mf_->NewEntry());
|
||||||
*entry_->mutable_key() = key_;
|
*entry_->mutable_key() = key_;
|
||||||
if (!entry_->MergePartialFromCodedStream(input)) return false;
|
const bool result = entry_->MergePartialFromCodedStream(input);
|
||||||
return UseKeyAndValueFromEntry();
|
if (result) UseKeyAndValueFromEntry();
|
||||||
|
if (entry_->GetArena() != NULL) entry_.release();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Key& key() const { return key_; }
|
const Key& key() const { return key_; }
|
||||||
const Value& value() const { return *value_ptr_; }
|
const Value& value() const { return *value_ptr_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD {
|
void UseKeyAndValueFromEntry() GOOGLE_PROTOBUF_ATTRIBUTE_COLD {
|
||||||
// Update key_ in case we need it later (because key() is called).
|
// Update key_ in case we need it later (because key() is called).
|
||||||
// This is potentially inefficient, especially if the key is
|
// This is potentially inefficient, especially if the key is
|
||||||
// expensive to copy (e.g., a long string), but this is a cold
|
// expensive to copy (e.g., a long string), but this is a cold
|
||||||
@@ -377,15 +398,13 @@ class MapEntryLite : public MessageLite {
|
|||||||
ValueTypeHandler::kWireType ==
|
ValueTypeHandler::kWireType ==
|
||||||
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
|
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
|
||||||
Value>::Move(entry_->mutable_value(), value_ptr_);
|
Value>::Move(entry_->mutable_value(), value_ptr_);
|
||||||
if (entry_->GetArena() != NULL) entry_.release();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// After reading a key and value successfully, and inserting that data
|
// After reading a key and value successfully, and inserting that data
|
||||||
// into map_, we are not at the end of the input. This is unusual, but
|
// into map_, we are not at the end of the input. This is unusual, but
|
||||||
// allowed by the spec.
|
// allowed by the spec.
|
||||||
bool ReadBeyondKeyValuePair(::google::protobuf::io::CodedInputStream* input)
|
bool ReadBeyondKeyValuePair(::google::protobuf::io::CodedInputStream* input)
|
||||||
GOOGLE_ATTRIBUTE_COLD {
|
GOOGLE_PROTOBUF_ATTRIBUTE_COLD {
|
||||||
typedef MoveHelper<KeyTypeHandler::kIsEnum,
|
typedef MoveHelper<KeyTypeHandler::kIsEnum,
|
||||||
KeyTypeHandler::kIsMessage,
|
KeyTypeHandler::kIsMessage,
|
||||||
KeyTypeHandler::kWireType ==
|
KeyTypeHandler::kWireType ==
|
||||||
@@ -400,16 +419,19 @@ class MapEntryLite : public MessageLite {
|
|||||||
ValueMover::Move(value_ptr_, entry_->mutable_value());
|
ValueMover::Move(value_ptr_, entry_->mutable_value());
|
||||||
map_->erase(key_);
|
map_->erase(key_);
|
||||||
KeyMover::Move(&key_, entry_->mutable_key());
|
KeyMover::Move(&key_, entry_->mutable_key());
|
||||||
if (!entry_->MergePartialFromCodedStream(input)) return false;
|
const bool result = entry_->MergePartialFromCodedStream(input);
|
||||||
return UseKeyAndValueFromEntry();
|
if (result) UseKeyAndValueFromEntry();
|
||||||
|
if (entry_->GetArena() != NULL) entry_.release();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapField* const mf_;
|
MapField* const mf_;
|
||||||
Map* const map_;
|
Map* const map_;
|
||||||
Key key_;
|
Key key_;
|
||||||
Value* value_ptr_;
|
Value* value_ptr_;
|
||||||
// On the fast path entry_ is not used.
|
// On the fast path entry_ is not used. And, when entry_ is used, it's set
|
||||||
google::protobuf::scoped_ptr<MapEntryLite> entry_;
|
// to mf_->NewEntry(), so in the arena case we must call entry_.release.
|
||||||
|
google::protobuf::scoped_ptr<MapEntryImpl> entry_;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -431,21 +453,17 @@ class MapEntryLite : public MessageLite {
|
|||||||
// involves copy of key and value to construct a MapEntry. In order to avoid
|
// involves copy of key and value to construct a MapEntry. In order to avoid
|
||||||
// this copy in constructing a MapEntry, we need the following class which
|
// this copy in constructing a MapEntry, we need the following class which
|
||||||
// only takes references of given key and value.
|
// only takes references of given key and value.
|
||||||
template <typename K, typename V, WireFormatLite::FieldType k_wire_type,
|
class MapEntryWrapper : public Derived {
|
||||||
WireFormatLite::FieldType v_wire_type, int default_enum>
|
typedef Derived BaseClass;
|
||||||
class MapEntryWrapper
|
typedef typename BaseClass::KeyMapEntryAccessorType KeyMapEntryAccessorType;
|
||||||
: public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {
|
typedef
|
||||||
typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;
|
typename BaseClass::ValueMapEntryAccessorType ValueMapEntryAccessorType;
|
||||||
typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;
|
|
||||||
typedef typename Base::ValueMapEntryAccessorType ValueMapEntryAccessorType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapEntryWrapper(Arena* arena, const K& key, const V& value)
|
MapEntryWrapper(Arena* arena, const Key& key, const Value& value)
|
||||||
: MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum>(arena),
|
: Derived(arena), key_(key), value_(value) {
|
||||||
key_(key),
|
BaseClass::set_has_key();
|
||||||
value_(value) {
|
BaseClass::set_has_value();
|
||||||
Base::set_has_key();
|
|
||||||
Base::set_has_value();
|
|
||||||
}
|
}
|
||||||
inline const KeyMapEntryAccessorType& key() const { return key_; }
|
inline const KeyMapEntryAccessorType& key() const { return key_; }
|
||||||
inline const ValueMapEntryAccessorType& value() const { return value_; }
|
inline const ValueMapEntryAccessorType& value() const { return value_; }
|
||||||
@@ -465,21 +483,17 @@ class MapEntryLite : public MessageLite {
|
|||||||
// initialize a reference to int with a reference to enum, compiler will
|
// initialize a reference to int with a reference to enum, compiler will
|
||||||
// generate a temporary int from enum and initialize the reference to int with
|
// generate a temporary int from enum and initialize the reference to int with
|
||||||
// the temporary.
|
// the temporary.
|
||||||
template <typename K, typename V, WireFormatLite::FieldType k_wire_type,
|
class MapEnumEntryWrapper : public Derived {
|
||||||
WireFormatLite::FieldType v_wire_type, int default_enum>
|
typedef Derived BaseClass;
|
||||||
class MapEnumEntryWrapper
|
typedef typename BaseClass::KeyMapEntryAccessorType KeyMapEntryAccessorType;
|
||||||
: public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {
|
typedef
|
||||||
typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;
|
typename BaseClass::ValueMapEntryAccessorType ValueMapEntryAccessorType;
|
||||||
typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;
|
|
||||||
typedef typename Base::ValueMapEntryAccessorType ValueMapEntryAccessorType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapEnumEntryWrapper(Arena* arena, const K& key, const V& value)
|
MapEnumEntryWrapper(Arena* arena, const Key& key, const Value& value)
|
||||||
: MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum>(arena),
|
: Derived(arena), key_(key), value_(value) {
|
||||||
key_(key),
|
BaseClass::set_has_key();
|
||||||
value_(value) {
|
BaseClass::set_has_value();
|
||||||
Base::set_has_key();
|
|
||||||
Base::set_has_value();
|
|
||||||
}
|
}
|
||||||
inline const KeyMapEntryAccessorType& key() const { return key_; }
|
inline const KeyMapEntryAccessorType& key() const { return key_; }
|
||||||
inline const ValueMapEntryAccessorType& value() const { return value_; }
|
inline const ValueMapEntryAccessorType& value() const { return value_; }
|
||||||
@@ -492,48 +506,62 @@ class MapEntryLite : public MessageLite {
|
|||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MapEntryLite() : default_instance_(NULL), arena_(NULL) {
|
|
||||||
KeyTypeHandler::Initialize(&key_, NULL);
|
|
||||||
ValueTypeHandler::InitializeMaybeByDefaultEnum(
|
|
||||||
&value_, default_enum_value, NULL);
|
|
||||||
_has_bits_[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit MapEntryLite(Arena* arena)
|
|
||||||
: default_instance_(NULL), arena_(arena) {
|
|
||||||
KeyTypeHandler::Initialize(&key_, arena);
|
|
||||||
ValueTypeHandler::InitializeMaybeByDefaultEnum(
|
|
||||||
&value_, default_enum_value, arena);
|
|
||||||
_has_bits_[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Arena* GetArenaNoVirtual() const {
|
inline Arena* GetArenaNoVirtual() const {
|
||||||
return arena_;
|
return arena_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_default_instance(MapEntryLite* default_instance) {
|
public: // Needed for constructing tables
|
||||||
default_instance_ = default_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapEntryLite* default_instance_;
|
|
||||||
|
|
||||||
KeyOnMemory key_;
|
KeyOnMemory key_;
|
||||||
ValueOnMemory value_;
|
ValueOnMemory value_;
|
||||||
Arena* arena_;
|
Arena* arena_;
|
||||||
uint32 _has_bits_[1];
|
uint32 _has_bits_[1];
|
||||||
|
|
||||||
|
private:
|
||||||
friend class ::google::protobuf::Arena;
|
friend class ::google::protobuf::Arena;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
template <typename K, typename V, WireFormatLite::FieldType,
|
template <typename C, typename K, typename V, WireFormatLite::FieldType,
|
||||||
WireFormatLite::FieldType, int>
|
WireFormatLite::FieldType, int>
|
||||||
friend class internal::MapEntry;
|
friend class internal::MapEntry;
|
||||||
template <typename K, typename V, WireFormatLite::FieldType,
|
template <typename C, typename K, typename V, WireFormatLite::FieldType,
|
||||||
WireFormatLite::FieldType, int>
|
WireFormatLite::FieldType, int>
|
||||||
friend class internal::MapFieldLite;
|
friend class internal::MapFieldLite;
|
||||||
|
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename Key, typename Value,
|
||||||
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
|
class MapEntryLite
|
||||||
|
: public MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value> {
|
||||||
|
public:
|
||||||
|
typedef MapEntryImpl<T, MessageLite, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value>
|
||||||
|
SuperType;
|
||||||
|
MapEntryLite() {}
|
||||||
|
explicit MapEntryLite(Arena* arena) : SuperType(arena) {}
|
||||||
|
void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); }
|
||||||
|
|
||||||
|
private:
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite);
|
||||||
};
|
};
|
||||||
|
// The completely unprincipled and unwieldy use of template parameters in
|
||||||
|
// the map code necessitates wrappers to make the code a little bit more
|
||||||
|
// manageable.
|
||||||
|
template <typename Derived>
|
||||||
|
struct DeconstructMapEntry;
|
||||||
|
|
||||||
|
template <typename T, typename K, typename V, WireFormatLite::FieldType key,
|
||||||
|
WireFormatLite::FieldType value, int default_enum>
|
||||||
|
struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value, default_enum> > {
|
||||||
|
typedef K Key;
|
||||||
|
typedef V Value;
|
||||||
|
static const WireFormatLite::FieldType kKeyFieldType = key;
|
||||||
|
static const WireFormatLite::FieldType kValueFieldType = value;
|
||||||
|
static const int default_enum_value = default_enum;
|
||||||
|
};
|
||||||
|
|
||||||
// Helpers for deterministic serialization =============================
|
// Helpers for deterministic serialization =============================
|
||||||
|
|
||||||
@@ -561,6 +589,76 @@ template <typename T> struct CompareByDerefFirst {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper for table driven serialization
|
||||||
|
|
||||||
|
template <WireFormatLite::FieldType FieldType>
|
||||||
|
struct FromHelper {
|
||||||
|
template <typename T>
|
||||||
|
static const T& From(const T& x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct FromHelper<WireFormatLite::TYPE_STRING> {
|
||||||
|
static ArenaStringPtr From(const string& x) {
|
||||||
|
ArenaStringPtr res;
|
||||||
|
*res.UnsafeRawStringPointer() = const_cast<string*>(&x);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct FromHelper<WireFormatLite::TYPE_BYTES> {
|
||||||
|
static ArenaStringPtr From(const string& x) {
|
||||||
|
ArenaStringPtr res;
|
||||||
|
*res.UnsafeRawStringPointer() = const_cast<string*>(&x);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <>
|
||||||
|
struct FromHelper<WireFormatLite::TYPE_MESSAGE> {
|
||||||
|
template <typename T>
|
||||||
|
static T* From(const T& x) {
|
||||||
|
return const_cast<T*>(&x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename MapEntryType>
|
||||||
|
struct MapEntryHelper;
|
||||||
|
|
||||||
|
template <typename T, typename Key, typename Value,
|
||||||
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
|
struct MapEntryHelper<MapEntryLite<T, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value> > {
|
||||||
|
// Provide utilities to parse/serialize key/value. Provide utilities to
|
||||||
|
// manipulate internal stored type.
|
||||||
|
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
||||||
|
typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;
|
||||||
|
|
||||||
|
// Define internal memory layout. Strings and messages are stored as
|
||||||
|
// pointers, while other types are stored as values.
|
||||||
|
typedef typename KeyTypeHandler::TypeOnMemory KeyOnMemory;
|
||||||
|
typedef typename ValueTypeHandler::TypeOnMemory ValueOnMemory;
|
||||||
|
|
||||||
|
explicit MapEntryHelper(const MapPair<Key, Value>& map_pair)
|
||||||
|
: _has_bits_(3),
|
||||||
|
_cached_size_(2 + KeyTypeHandler::GetCachedSize(map_pair.first) +
|
||||||
|
ValueTypeHandler::GetCachedSize(map_pair.second)),
|
||||||
|
key_(FromHelper<kKeyFieldType>::From(map_pair.first)),
|
||||||
|
value_(FromHelper<kValueFieldType>::From(map_pair.second)) {}
|
||||||
|
|
||||||
|
// Purposely not folowing the style guide naming. These are the names
|
||||||
|
// the proto compiler would generate given the map entry descriptor.
|
||||||
|
// The proto compiler generates the offsets in this struct as if this was
|
||||||
|
// a regular message. This way the table driven code barely notices it's
|
||||||
|
// dealing with a map field.
|
||||||
|
uint32 _has_bits_; // NOLINT
|
||||||
|
uint32 _cached_size_; // NOLINT
|
||||||
|
KeyOnMemory key_; // NOLINT
|
||||||
|
ValueOnMemory value_; // NOLINT
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|||||||
+21
-38
@@ -37,31 +37,6 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
ProtobufOnceType map_entry_default_instances_once_;
|
|
||||||
Mutex* map_entry_default_instances_mutex_;
|
|
||||||
vector<MessageLite*>* map_entry_default_instances_;
|
|
||||||
|
|
||||||
void DeleteMapEntryDefaultInstances() {
|
|
||||||
for (int i = 0; i < map_entry_default_instances_->size(); ++i) {
|
|
||||||
delete map_entry_default_instances_->at(i);
|
|
||||||
}
|
|
||||||
delete map_entry_default_instances_mutex_;
|
|
||||||
delete map_entry_default_instances_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitMapEntryDefaultInstances() {
|
|
||||||
map_entry_default_instances_mutex_ = new Mutex();
|
|
||||||
map_entry_default_instances_ = new vector<MessageLite*>();
|
|
||||||
OnShutdown(&DeleteMapEntryDefaultInstances);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterMapEntryDefaultInstance(MessageLite* default_instance) {
|
|
||||||
::google::protobuf::GoogleOnceInit(&map_entry_default_instances_once_,
|
|
||||||
&InitMapEntryDefaultInstances);
|
|
||||||
MutexLock lock(map_entry_default_instances_mutex_);
|
|
||||||
map_entry_default_instances_->push_back(default_instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
MapFieldBase::~MapFieldBase() {
|
MapFieldBase::~MapFieldBase() {
|
||||||
if (repeated_field_ != NULL && arena_ == NULL) delete repeated_field_;
|
if (repeated_field_ != NULL && arena_ == NULL) delete repeated_field_;
|
||||||
}
|
}
|
||||||
@@ -77,25 +52,26 @@ RepeatedPtrFieldBase* MapFieldBase::MutableRepeatedField() {
|
|||||||
return repeated_field_;
|
return repeated_field_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapFieldBase::SpaceUsedExcludingSelf() const {
|
size_t MapFieldBase::SpaceUsedExcludingSelfLong() const {
|
||||||
mutex_.Lock();
|
mutex_.Lock();
|
||||||
int size = SpaceUsedExcludingSelfNoLock();
|
size_t size = SpaceUsedExcludingSelfNoLock();
|
||||||
mutex_.Unlock();
|
mutex_.Unlock();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapFieldBase::SpaceUsedExcludingSelfNoLock() const {
|
size_t MapFieldBase::SpaceUsedExcludingSelfNoLock() const {
|
||||||
if (repeated_field_ != NULL) {
|
if (repeated_field_ != NULL) {
|
||||||
return repeated_field_->SpaceUsedExcludingSelf();
|
return repeated_field_->SpaceUsedExcludingSelfLong();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapFieldBase::InitMetadataOnce() const {
|
bool MapFieldBase::IsMapValid() const {
|
||||||
GOOGLE_CHECK(entry_descriptor_ != NULL);
|
// "Acquire" insures the operation after SyncRepeatedFieldWithMap won't get
|
||||||
GOOGLE_CHECK(assign_descriptor_callback_ != NULL);
|
// executed before state_ is checked.
|
||||||
(*assign_descriptor_callback_)();
|
Atomic32 state = google::protobuf::internal::Acquire_Load(&state_);
|
||||||
|
return state != STATE_MODIFIED_REPEATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapFieldBase::SetMapDirty() { state_ = STATE_MODIFIED_MAP; }
|
void MapFieldBase::SetMapDirty() { state_ = STATE_MODIFIED_MAP; }
|
||||||
@@ -390,6 +366,13 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {
|
|||||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove existing map value with same key.
|
||||||
|
Map<MapKey, MapValueRef>::iterator iter = map->find(map_key);
|
||||||
|
if (iter != map->end()) {
|
||||||
|
iter->second.DeleteData();
|
||||||
|
}
|
||||||
|
|
||||||
MapValueRef& map_val = (*map)[map_key];
|
MapValueRef& map_val = (*map)[map_key];
|
||||||
map_val.SetType(val_des->cpp_type());
|
map_val.SetType(val_des->cpp_type());
|
||||||
switch (val_des->cpp_type()) {
|
switch (val_des->cpp_type()) {
|
||||||
@@ -421,13 +404,13 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DynamicMapField::SpaceUsedExcludingSelfNoLock() const {
|
size_t DynamicMapField::SpaceUsedExcludingSelfNoLock() const {
|
||||||
int size = 0;
|
size_t size = 0;
|
||||||
if (MapFieldBase::repeated_field_ != NULL) {
|
if (MapFieldBase::repeated_field_ != NULL) {
|
||||||
size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf();
|
size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelfLong();
|
||||||
}
|
}
|
||||||
size += sizeof(map_);
|
size += sizeof(map_);
|
||||||
int map_size = map_.size();
|
size_t map_size = map_.size();
|
||||||
if (map_size) {
|
if (map_size) {
|
||||||
Map<MapKey, MapValueRef>::const_iterator it = map_.begin();
|
Map<MapKey, MapValueRef>::const_iterator it = map_.begin();
|
||||||
size += sizeof(it->first) * map_size;
|
size += sizeof(it->first) * map_size;
|
||||||
@@ -456,7 +439,7 @@ int DynamicMapField::SpaceUsedExcludingSelfNoLock() const {
|
|||||||
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {
|
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {
|
||||||
while (it != map_.end()) {
|
while (it != map_.end()) {
|
||||||
const Message& message = it->second.GetMessageValue();
|
const Message& message = it->second.GetMessageValue();
|
||||||
size += message.GetReflection()->SpaceUsed(message);
|
size += message.GetReflection()->SpaceUsedLong(message);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+501
-60
@@ -36,6 +36,7 @@
|
|||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
|
#include <google/protobuf/descriptor.h>
|
||||||
#include <google/protobuf/map_entry.h>
|
#include <google/protobuf/map_entry.h>
|
||||||
#include <google/protobuf/map_field_lite.h>
|
#include <google/protobuf/map_field_lite.h>
|
||||||
#include <google/protobuf/map_type_handler.h>
|
#include <google/protobuf/map_type_handler.h>
|
||||||
@@ -62,14 +63,10 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
MapFieldBase()
|
MapFieldBase()
|
||||||
: arena_(NULL),
|
: arena_(NULL),
|
||||||
repeated_field_(NULL),
|
repeated_field_(NULL),
|
||||||
entry_descriptor_(NULL),
|
|
||||||
assign_descriptor_callback_(NULL),
|
|
||||||
state_(STATE_MODIFIED_MAP) {}
|
state_(STATE_MODIFIED_MAP) {}
|
||||||
explicit MapFieldBase(Arena* arena)
|
explicit MapFieldBase(Arena* arena)
|
||||||
: arena_(arena),
|
: arena_(arena),
|
||||||
repeated_field_(NULL),
|
repeated_field_(NULL),
|
||||||
entry_descriptor_(NULL),
|
|
||||||
assign_descriptor_callback_(NULL),
|
|
||||||
state_(STATE_MODIFIED_MAP) {
|
state_(STATE_MODIFIED_MAP) {
|
||||||
// Mutex's destructor needs to be called explicitly to release resources
|
// Mutex's destructor needs to be called explicitly to release resources
|
||||||
// acquired in its constructor.
|
// acquired in its constructor.
|
||||||
@@ -89,6 +86,8 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
virtual bool ContainsMapKey(const MapKey& map_key) const = 0;
|
virtual bool ContainsMapKey(const MapKey& map_key) const = 0;
|
||||||
virtual bool InsertOrLookupMapValue(
|
virtual bool InsertOrLookupMapValue(
|
||||||
const MapKey& map_key, MapValueRef* val) = 0;
|
const MapKey& map_key, MapValueRef* val) = 0;
|
||||||
|
// Insures operations after won't get executed before calling this.
|
||||||
|
bool IsMapValid() const;
|
||||||
virtual bool DeleteMapValue(const MapKey& map_key) = 0;
|
virtual bool DeleteMapValue(const MapKey& map_key) = 0;
|
||||||
virtual bool EqualIterator(const MapIterator& a,
|
virtual bool EqualIterator(const MapIterator& a,
|
||||||
const MapIterator& b) const = 0;
|
const MapIterator& b) const = 0;
|
||||||
@@ -99,11 +98,15 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
|
|
||||||
// Returns the number of bytes used by the repeated field, excluding
|
// Returns the number of bytes used by the repeated field, excluding
|
||||||
// sizeof(*this)
|
// sizeof(*this)
|
||||||
int SpaceUsedExcludingSelf() const;
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
|
|
||||||
|
int SpaceUsedExcludingSelf() const {
|
||||||
|
return internal::ToIntSize(SpaceUsedExcludingSelfLong());
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Gets the size of space used by map field.
|
// Gets the size of space used by map field.
|
||||||
virtual int SpaceUsedExcludingSelfNoLock() const;
|
virtual size_t SpaceUsedExcludingSelfNoLock() const;
|
||||||
|
|
||||||
// Synchronizes the content in Map to RepeatedPtrField if there is any change
|
// Synchronizes the content in Map to RepeatedPtrField if there is any change
|
||||||
// to Map after last synchronization.
|
// to Map after last synchronization.
|
||||||
@@ -124,9 +127,6 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
// Provides derived class the access to repeated field.
|
// Provides derived class the access to repeated field.
|
||||||
void* MutableRepeatedPtrField() const;
|
void* MutableRepeatedPtrField() const;
|
||||||
|
|
||||||
// Creates descriptor for only one time.
|
|
||||||
void InitMetadataOnce() const;
|
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
STATE_MODIFIED_MAP = 0, // map has newly added data that has not been
|
STATE_MODIFIED_MAP = 0, // map has newly added data that has not been
|
||||||
// synchronized to repeated field
|
// synchronized to repeated field
|
||||||
@@ -137,13 +137,6 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
|
|
||||||
Arena* arena_;
|
Arena* arena_;
|
||||||
mutable RepeatedPtrField<Message>* repeated_field_;
|
mutable RepeatedPtrField<Message>* repeated_field_;
|
||||||
// MapEntry can only be created from MapField. To create MapEntry, MapField
|
|
||||||
// needs to know its descriptor, because MapEntry is not generated class which
|
|
||||||
// cannot initialize its own descriptor by calling generated
|
|
||||||
// descriptor-assign-function. Thus, we need to register a callback to
|
|
||||||
// initialize MapEntry's descriptor.
|
|
||||||
const Descriptor** entry_descriptor_;
|
|
||||||
void (*assign_descriptor_callback_)();
|
|
||||||
|
|
||||||
mutable Mutex mutex_; // The thread to synchronize map and repeated field
|
mutable Mutex mutex_; // The thread to synchronize map and repeated field
|
||||||
// needs to get lock first;
|
// needs to get lock first;
|
||||||
@@ -177,6 +170,7 @@ class LIBPROTOBUF_EXPORT MapFieldBase {
|
|||||||
// IncreaseIterator() is called by operator++() of MapIterator only.
|
// IncreaseIterator() is called by operator++() of MapIterator only.
|
||||||
// It implements the ++ operator of MapIterator.
|
// It implements the ++ operator of MapIterator.
|
||||||
virtual void IncreaseIterator(MapIterator* map_iter) const = 0;
|
virtual void IncreaseIterator(MapIterator* map_iter) const = 0;
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class provides common Map Reflection implementations for generated
|
// This class provides common Map Reflection implementations for generated
|
||||||
@@ -206,32 +200,31 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
|
|||||||
void IncreaseIterator(MapIterator* map_iter) const;
|
void IncreaseIterator(MapIterator* map_iter) const;
|
||||||
|
|
||||||
virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;
|
virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class provides access to map field using generated api. It is used for
|
// This class provides access to map field using generated api. It is used for
|
||||||
// internal generated message implentation only. Users should never use this
|
// internal generated message implentation only. Users should never use this
|
||||||
// directly.
|
// directly.
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value = 0>
|
||||||
int default_enum_value = 0>
|
class MapField : public TypeDefinedMapFieldBase<Key, T> {
|
||||||
class MapField : public TypeDefinedMapFieldBase<Key, T>,
|
|
||||||
public MapFieldLite<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value> {
|
|
||||||
// Provide utilities to parse/serialize key/value. Provide utilities to
|
// Provide utilities to parse/serialize key/value. Provide utilities to
|
||||||
// manipulate internal stored type.
|
// manipulate internal stored type.
|
||||||
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;
|
||||||
typedef MapTypeHandler<kValueFieldType, T> ValueTypeHandler;
|
typedef MapTypeHandler<kValueFieldType, T> ValueTypeHandler;
|
||||||
|
|
||||||
// Define message type for internal repeated field.
|
// Define message type for internal repeated field.
|
||||||
typedef MapEntry<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>
|
typedef Derived EntryType;
|
||||||
EntryType;
|
typedef MapEntryLite<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
typedef MapEntryLite<Key, T, kKeyFieldType, kValueFieldType,
|
default_enum_value>
|
||||||
default_enum_value> EntryLiteType;
|
EntryLiteType;
|
||||||
|
|
||||||
// Define abbreviation for parent MapFieldLite
|
// Define abbreviation for parent MapFieldLite
|
||||||
typedef MapFieldLite<Key, T, kKeyFieldType, kValueFieldType,
|
typedef MapFieldLite<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
default_enum_value> MapFieldLiteType;
|
default_enum_value>
|
||||||
|
MapFieldLiteType;
|
||||||
|
|
||||||
// Enum needs to be handled differently from other types because it has
|
// Enum needs to be handled differently from other types because it has
|
||||||
// different exposed type in google::protobuf::Map's api and repeated field's api. For
|
// different exposed type in google::protobuf::Map's api and repeated field's api. For
|
||||||
@@ -241,58 +234,76 @@ class MapField : public TypeDefinedMapFieldBase<Key, T>,
|
|||||||
typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType;
|
typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapField();
|
typedef typename Derived::SuperType EntryTypeTrait;
|
||||||
explicit MapField(Arena* arena);
|
typedef Map<Key, T> MapType;
|
||||||
// MapField doesn't own the default_entry, which means default_entry must
|
|
||||||
// outlive the lifetime of MapField.
|
MapField() {}
|
||||||
MapField(const Message* default_entry);
|
explicit MapField(Arena* arena)
|
||||||
// For tests only.
|
: TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
|
||||||
MapField(Arena* arena, const Message* default_entry);
|
|
||||||
~MapField();
|
|
||||||
|
|
||||||
// Implement MapFieldBase
|
// Implement MapFieldBase
|
||||||
bool ContainsMapKey(const MapKey& map_key) const;
|
bool ContainsMapKey(const MapKey& map_key) const;
|
||||||
bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);
|
bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);
|
||||||
bool DeleteMapValue(const MapKey& map_key);
|
bool DeleteMapValue(const MapKey& map_key);
|
||||||
|
|
||||||
// Accessors
|
const Map<Key, T>& GetMap() const {
|
||||||
const Map<Key, T>& GetMap() const;
|
MapFieldBase::SyncMapWithRepeatedField();
|
||||||
Map<Key, T>* MutableMap();
|
return impl_.GetMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Key, T>* MutableMap() {
|
||||||
|
MapFieldBase::SyncMapWithRepeatedField();
|
||||||
|
Map<Key, T>* result = impl_.MutableMap();
|
||||||
|
MapFieldBase::SetMapDirty();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Convenient methods for generated message implementation.
|
// Convenient methods for generated message implementation.
|
||||||
int size() const;
|
int size() const;
|
||||||
void Clear();
|
void Clear();
|
||||||
void MergeFrom(const MapFieldLiteType& other);
|
void MergeFrom(const MapField& other);
|
||||||
void Swap(MapFieldLiteType* other);
|
void Swap(MapField* other);
|
||||||
|
|
||||||
// Allocates metadata only if this MapField is part of a generated message.
|
// Used in the implementation of parsing. Caller should take the ownership iff
|
||||||
void SetEntryDescriptor(const Descriptor** descriptor);
|
// arena_ is NULL.
|
||||||
void SetAssignDescriptorCallback(void (*callback)());
|
EntryType* NewEntry() const { return impl_.NewEntry(); }
|
||||||
|
// Used in the implementation of serializing enum value type. Caller should
|
||||||
|
// take the ownership iff arena_ is NULL.
|
||||||
|
EntryType* NewEnumEntryWrapper(const Key& key, const T t) const {
|
||||||
|
return impl_.NewEnumEntryWrapper(key, t);
|
||||||
|
}
|
||||||
|
// Used in the implementation of serializing other value types. Caller should
|
||||||
|
// take the ownership iff arena_ is NULL.
|
||||||
|
EntryType* NewEntryWrapper(const Key& key, const T& t) const {
|
||||||
|
return impl_.NewEntryWrapper(key, t);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MapFieldLiteType impl_;
|
||||||
|
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
|
|
||||||
// MapField needs MapEntry's default instance to create new MapEntry.
|
|
||||||
void InitDefaultEntryOnce() const;
|
|
||||||
|
|
||||||
// Manually set default entry instance. For test only.
|
|
||||||
void SetDefaultEntryOnce(const EntryType* default_entry) const;
|
|
||||||
|
|
||||||
// Convenient methods to get internal google::protobuf::Map
|
|
||||||
const Map<Key, T>& GetInternalMap() const;
|
|
||||||
Map<Key, T>* MutableInternalMap();
|
|
||||||
|
|
||||||
// Implements MapFieldBase
|
// Implements MapFieldBase
|
||||||
void SyncRepeatedFieldWithMapNoLock() const;
|
void SyncRepeatedFieldWithMapNoLock() const;
|
||||||
void SyncMapWithRepeatedFieldNoLock() const;
|
void SyncMapWithRepeatedFieldNoLock() const;
|
||||||
int SpaceUsedExcludingSelfNoLock() const;
|
size_t SpaceUsedExcludingSelfNoLock() const;
|
||||||
|
|
||||||
void SetMapIteratorValue(MapIterator* map_iter) const;
|
void SetMapIteratorValue(MapIterator* map_iter) const;
|
||||||
|
|
||||||
mutable const EntryType* default_entry_;
|
|
||||||
|
|
||||||
friend class ::google::protobuf::Arena;
|
friend class ::google::protobuf::Arena;
|
||||||
|
friend class MapFieldStateTest; // For testing, it needs raw access to impl_
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename Key, typename Value,
|
||||||
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
|
struct MapEntryToMapField<MapEntry<T, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value> > {
|
||||||
|
typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType,
|
||||||
|
default_enum_value>
|
||||||
|
MapFieldType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
|
class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
|
||||||
@@ -318,12 +329,401 @@ class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey,
|
|||||||
// Implements MapFieldBase
|
// Implements MapFieldBase
|
||||||
void SyncRepeatedFieldWithMapNoLock() const;
|
void SyncRepeatedFieldWithMapNoLock() const;
|
||||||
void SyncMapWithRepeatedFieldNoLock() const;
|
void SyncMapWithRepeatedFieldNoLock() const;
|
||||||
int SpaceUsedExcludingSelfNoLock() const;
|
size_t SpaceUsedExcludingSelfNoLock() const;
|
||||||
void SetMapIteratorValue(MapIterator* map_iter) const;
|
void SetMapIteratorValue(MapIterator* map_iter) const;
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMapField);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
|
||||||
|
if (type() != EXPECTEDTYPE) { \
|
||||||
|
GOOGLE_LOG(FATAL) \
|
||||||
|
<< "Protocol Buffer map usage error:\n" \
|
||||||
|
<< METHOD << " type does not match\n" \
|
||||||
|
<< " Expected : " \
|
||||||
|
<< FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
|
||||||
|
<< " Actual : " \
|
||||||
|
<< FieldDescriptor::CppTypeName(type()); \
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapKey is an union type for representing any possible
|
||||||
|
// map key.
|
||||||
|
class LIBPROTOBUF_EXPORT MapKey {
|
||||||
|
public:
|
||||||
|
MapKey() : type_(0) {
|
||||||
|
}
|
||||||
|
MapKey(const MapKey& other) : type_(0) {
|
||||||
|
CopyFrom(other);
|
||||||
|
}
|
||||||
|
MapKey& operator=(const MapKey& other) {
|
||||||
|
CopyFrom(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~MapKey() {
|
||||||
|
if (type_ == FieldDescriptor::CPPTYPE_STRING) {
|
||||||
|
delete val_.string_value_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldDescriptor::CppType type() const {
|
||||||
|
if (type_ == 0) {
|
||||||
|
GOOGLE_LOG(FATAL)
|
||||||
|
<< "Protocol Buffer map usage error:\n"
|
||||||
|
<< "MapKey::type MapKey is not initialized. "
|
||||||
|
<< "Call set methods to initialize MapKey.";
|
||||||
|
}
|
||||||
|
return (FieldDescriptor::CppType)type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetInt64Value(int64 value) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_INT64);
|
||||||
|
val_.int64_value_ = value;
|
||||||
|
}
|
||||||
|
void SetUInt64Value(uint64 value) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_UINT64);
|
||||||
|
val_.uint64_value_ = value;
|
||||||
|
}
|
||||||
|
void SetInt32Value(int32 value) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_INT32);
|
||||||
|
val_.int32_value_ = value;
|
||||||
|
}
|
||||||
|
void SetUInt32Value(uint32 value) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_UINT32);
|
||||||
|
val_.uint32_value_ = value;
|
||||||
|
}
|
||||||
|
void SetBoolValue(bool value) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_BOOL);
|
||||||
|
val_.bool_value_ = value;
|
||||||
|
}
|
||||||
|
void SetStringValue(const string& val) {
|
||||||
|
SetType(FieldDescriptor::CPPTYPE_STRING);
|
||||||
|
*val_.string_value_ = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 GetInt64Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,
|
||||||
|
"MapKey::GetInt64Value");
|
||||||
|
return val_.int64_value_;
|
||||||
|
}
|
||||||
|
uint64 GetUInt64Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,
|
||||||
|
"MapKey::GetUInt64Value");
|
||||||
|
return val_.uint64_value_;
|
||||||
|
}
|
||||||
|
int32 GetInt32Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,
|
||||||
|
"MapKey::GetInt32Value");
|
||||||
|
return val_.int32_value_;
|
||||||
|
}
|
||||||
|
uint32 GetUInt32Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,
|
||||||
|
"MapKey::GetUInt32Value");
|
||||||
|
return val_.uint32_value_;
|
||||||
|
}
|
||||||
|
bool GetBoolValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,
|
||||||
|
"MapKey::GetBoolValue");
|
||||||
|
return val_.bool_value_;
|
||||||
|
}
|
||||||
|
const string& GetStringValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
|
||||||
|
"MapKey::GetStringValue");
|
||||||
|
return *val_.string_value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const MapKey& other) const {
|
||||||
|
if (type_ != other.type_) {
|
||||||
|
// We could define a total order that handles this case, but
|
||||||
|
// there currently no need. So, for now, fail.
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
|
||||||
|
}
|
||||||
|
switch (type()) {
|
||||||
|
case FieldDescriptor::CPPTYPE_DOUBLE:
|
||||||
|
case FieldDescriptor::CPPTYPE_FLOAT:
|
||||||
|
case FieldDescriptor::CPPTYPE_ENUM:
|
||||||
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported";
|
||||||
|
return false;
|
||||||
|
case FieldDescriptor::CPPTYPE_STRING:
|
||||||
|
return *val_.string_value_ < *other.val_.string_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT64:
|
||||||
|
return val_.int64_value_ < other.val_.int64_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT32:
|
||||||
|
return val_.int32_value_ < other.val_.int32_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT64:
|
||||||
|
return val_.uint64_value_ < other.val_.uint64_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT32:
|
||||||
|
return val_.uint32_value_ < other.val_.uint32_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_BOOL:
|
||||||
|
return val_.bool_value_ < other.val_.bool_value_;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const MapKey& other) const {
|
||||||
|
if (type_ != other.type_) {
|
||||||
|
// To be consistent with operator<, we don't allow this either.
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
|
||||||
|
}
|
||||||
|
switch (type()) {
|
||||||
|
case FieldDescriptor::CPPTYPE_DOUBLE:
|
||||||
|
case FieldDescriptor::CPPTYPE_FLOAT:
|
||||||
|
case FieldDescriptor::CPPTYPE_ENUM:
|
||||||
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported";
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_STRING:
|
||||||
|
return *val_.string_value_ == *other.val_.string_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT64:
|
||||||
|
return val_.int64_value_ == other.val_.int64_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT32:
|
||||||
|
return val_.int32_value_ == other.val_.int32_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT64:
|
||||||
|
return val_.uint64_value_ == other.val_.uint64_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT32:
|
||||||
|
return val_.uint32_value_ == other.val_.uint32_value_;
|
||||||
|
case FieldDescriptor::CPPTYPE_BOOL:
|
||||||
|
return val_.bool_value_ == other.val_.bool_value_;
|
||||||
|
}
|
||||||
|
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyFrom(const MapKey& other) {
|
||||||
|
SetType(other.type());
|
||||||
|
switch (type_) {
|
||||||
|
case FieldDescriptor::CPPTYPE_DOUBLE:
|
||||||
|
case FieldDescriptor::CPPTYPE_FLOAT:
|
||||||
|
case FieldDescriptor::CPPTYPE_ENUM:
|
||||||
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported";
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_STRING:
|
||||||
|
*val_.string_value_ = *other.val_.string_value_;
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT64:
|
||||||
|
val_.int64_value_ = other.val_.int64_value_;
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_INT32:
|
||||||
|
val_.int32_value_ = other.val_.int32_value_;
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT64:
|
||||||
|
val_.uint64_value_ = other.val_.uint64_value_;
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_UINT32:
|
||||||
|
val_.uint32_value_ = other.val_.uint32_value_;
|
||||||
|
break;
|
||||||
|
case FieldDescriptor::CPPTYPE_BOOL:
|
||||||
|
val_.bool_value_ = other.val_.bool_value_;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename K, typename V>
|
||||||
|
friend class internal::TypeDefinedMapFieldBase;
|
||||||
|
friend class MapIterator;
|
||||||
|
friend class internal::DynamicMapField;
|
||||||
|
|
||||||
|
union KeyValue {
|
||||||
|
KeyValue() {}
|
||||||
|
string* string_value_;
|
||||||
|
int64 int64_value_;
|
||||||
|
int32 int32_value_;
|
||||||
|
uint64 uint64_value_;
|
||||||
|
uint32 uint32_value_;
|
||||||
|
bool bool_value_;
|
||||||
|
} val_;
|
||||||
|
|
||||||
|
void SetType(FieldDescriptor::CppType type) {
|
||||||
|
if (type_ == type) return;
|
||||||
|
if (type_ == FieldDescriptor::CPPTYPE_STRING) {
|
||||||
|
delete val_.string_value_;
|
||||||
|
}
|
||||||
|
type_ = type;
|
||||||
|
if (type_ == FieldDescriptor::CPPTYPE_STRING) {
|
||||||
|
val_.string_value_ = new string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// type_ is 0 or a valid FieldDescriptor::CppType.
|
||||||
|
int type_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// MapValueRef points to a map value.
|
||||||
|
class LIBPROTOBUF_EXPORT MapValueRef {
|
||||||
|
public:
|
||||||
|
MapValueRef() : data_(NULL), type_(0) {}
|
||||||
|
|
||||||
|
void SetInt64Value(int64 value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,
|
||||||
|
"MapValueRef::SetInt64Value");
|
||||||
|
*reinterpret_cast<int64*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetUInt64Value(uint64 value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,
|
||||||
|
"MapValueRef::SetUInt64Value");
|
||||||
|
*reinterpret_cast<uint64*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetInt32Value(int32 value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,
|
||||||
|
"MapValueRef::SetInt32Value");
|
||||||
|
*reinterpret_cast<int32*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetUInt32Value(uint32 value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,
|
||||||
|
"MapValueRef::SetUInt32Value");
|
||||||
|
*reinterpret_cast<uint32*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetBoolValue(bool value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,
|
||||||
|
"MapValueRef::SetBoolValue");
|
||||||
|
*reinterpret_cast<bool*>(data_) = value;
|
||||||
|
}
|
||||||
|
// TODO(jieluo) - Checks that enum is member.
|
||||||
|
void SetEnumValue(int value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM,
|
||||||
|
"MapValueRef::SetEnumValue");
|
||||||
|
*reinterpret_cast<int*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetStringValue(const string& value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
|
||||||
|
"MapValueRef::SetStringValue");
|
||||||
|
*reinterpret_cast<string*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetFloatValue(float value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,
|
||||||
|
"MapValueRef::SetFloatValue");
|
||||||
|
*reinterpret_cast<float*>(data_) = value;
|
||||||
|
}
|
||||||
|
void SetDoubleValue(double value) {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE,
|
||||||
|
"MapValueRef::SetDoubleValue");
|
||||||
|
*reinterpret_cast<double*>(data_) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 GetInt64Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,
|
||||||
|
"MapValueRef::GetInt64Value");
|
||||||
|
return *reinterpret_cast<int64*>(data_);
|
||||||
|
}
|
||||||
|
uint64 GetUInt64Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,
|
||||||
|
"MapValueRef::GetUInt64Value");
|
||||||
|
return *reinterpret_cast<uint64*>(data_);
|
||||||
|
}
|
||||||
|
int32 GetInt32Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,
|
||||||
|
"MapValueRef::GetInt32Value");
|
||||||
|
return *reinterpret_cast<int32*>(data_);
|
||||||
|
}
|
||||||
|
uint32 GetUInt32Value() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,
|
||||||
|
"MapValueRef::GetUInt32Value");
|
||||||
|
return *reinterpret_cast<uint32*>(data_);
|
||||||
|
}
|
||||||
|
bool GetBoolValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,
|
||||||
|
"MapValueRef::GetBoolValue");
|
||||||
|
return *reinterpret_cast<bool*>(data_);
|
||||||
|
}
|
||||||
|
int GetEnumValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM,
|
||||||
|
"MapValueRef::GetEnumValue");
|
||||||
|
return *reinterpret_cast<int*>(data_);
|
||||||
|
}
|
||||||
|
const string& GetStringValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,
|
||||||
|
"MapValueRef::GetStringValue");
|
||||||
|
return *reinterpret_cast<string*>(data_);
|
||||||
|
}
|
||||||
|
float GetFloatValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,
|
||||||
|
"MapValueRef::GetFloatValue");
|
||||||
|
return *reinterpret_cast<float*>(data_);
|
||||||
|
}
|
||||||
|
double GetDoubleValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE,
|
||||||
|
"MapValueRef::GetDoubleValue");
|
||||||
|
return *reinterpret_cast<double*>(data_);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Message& GetMessageValue() const {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_MESSAGE,
|
||||||
|
"MapValueRef::GetMessageValue");
|
||||||
|
return *reinterpret_cast<Message*>(data_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Message* MutableMessageValue() {
|
||||||
|
TYPE_CHECK(FieldDescriptor::CPPTYPE_MESSAGE,
|
||||||
|
"MapValueRef::MutableMessageValue");
|
||||||
|
return reinterpret_cast<Message*>(data_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename Derived, typename K, typename V,
|
||||||
|
internal::WireFormatLite::FieldType key_wire_type,
|
||||||
|
internal::WireFormatLite::FieldType value_wire_type,
|
||||||
|
int default_enum_value>
|
||||||
|
friend class internal::MapField;
|
||||||
|
template <typename K, typename V>
|
||||||
|
friend class internal::TypeDefinedMapFieldBase;
|
||||||
|
friend class MapIterator;
|
||||||
|
friend class internal::GeneratedMessageReflection;
|
||||||
|
friend class internal::DynamicMapField;
|
||||||
|
|
||||||
|
void SetType(FieldDescriptor::CppType type) {
|
||||||
|
type_ = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldDescriptor::CppType type() const {
|
||||||
|
if (type_ == 0 || data_ == NULL) {
|
||||||
|
GOOGLE_LOG(FATAL)
|
||||||
|
<< "Protocol Buffer map usage error:\n"
|
||||||
|
<< "MapValueRef::type MapValueRef is not initialized.";
|
||||||
|
}
|
||||||
|
return (FieldDescriptor::CppType)type_;
|
||||||
|
}
|
||||||
|
void SetValue(const void* val) {
|
||||||
|
data_ = const_cast<void*>(val);
|
||||||
|
}
|
||||||
|
void CopyFrom(const MapValueRef& other) {
|
||||||
|
type_ = other.type_;
|
||||||
|
data_ = other.data_;
|
||||||
|
}
|
||||||
|
// Only used in DynamicMapField
|
||||||
|
void DeleteData() {
|
||||||
|
switch (type_) {
|
||||||
|
#define HANDLE_TYPE(CPPTYPE, TYPE) \
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: { \
|
||||||
|
delete reinterpret_cast<TYPE*>(data_); \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
HANDLE_TYPE(INT32, int32);
|
||||||
|
HANDLE_TYPE(INT64, int64);
|
||||||
|
HANDLE_TYPE(UINT32, uint32);
|
||||||
|
HANDLE_TYPE(UINT64, uint64);
|
||||||
|
HANDLE_TYPE(DOUBLE, double);
|
||||||
|
HANDLE_TYPE(FLOAT, float);
|
||||||
|
HANDLE_TYPE(BOOL, bool);
|
||||||
|
HANDLE_TYPE(STRING, string);
|
||||||
|
HANDLE_TYPE(ENUM, int32);
|
||||||
|
HANDLE_TYPE(MESSAGE, Message);
|
||||||
|
#undef HANDLE_TYPE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// data_ point to a map value. MapValueRef does not
|
||||||
|
// own this value.
|
||||||
|
void* data_;
|
||||||
|
// type_ is 0 or a valid FieldDescriptor::CppType.
|
||||||
|
int type_;
|
||||||
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapValueRef);
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef TYPE_CHECK
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT MapIterator {
|
class LIBPROTOBUF_EXPORT MapIterator {
|
||||||
public:
|
public:
|
||||||
MapIterator(Message* message, const FieldDescriptor* field) {
|
MapIterator(Message* message, const FieldDescriptor* field) {
|
||||||
@@ -341,6 +741,11 @@ class LIBPROTOBUF_EXPORT MapIterator {
|
|||||||
~MapIterator() {
|
~MapIterator() {
|
||||||
map_->DeleteIterator(this);
|
map_->DeleteIterator(this);
|
||||||
}
|
}
|
||||||
|
MapIterator& operator=(const MapIterator& other) {
|
||||||
|
map_ = other.map_;
|
||||||
|
map_->CopyIterator(this, other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
friend bool operator==(const MapIterator& a, const MapIterator& b) {
|
friend bool operator==(const MapIterator& a, const MapIterator& b) {
|
||||||
return a.map_->EqualIterator(a, b);
|
return a.map_->EqualIterator(a, b);
|
||||||
}
|
}
|
||||||
@@ -373,7 +778,7 @@ class LIBPROTOBUF_EXPORT MapIterator {
|
|||||||
template <typename Key, typename T>
|
template <typename Key, typename T>
|
||||||
friend class internal::TypeDefinedMapFieldBase;
|
friend class internal::TypeDefinedMapFieldBase;
|
||||||
friend class internal::DynamicMapField;
|
friend class internal::DynamicMapField;
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
internal::WireFormatLite::FieldType kKeyFieldType,
|
internal::WireFormatLite::FieldType kKeyFieldType,
|
||||||
internal::WireFormatLite::FieldType kValueFieldType,
|
internal::WireFormatLite::FieldType kValueFieldType,
|
||||||
int default_enum_value>
|
int default_enum_value>
|
||||||
@@ -392,6 +797,42 @@ class LIBPROTOBUF_EXPORT MapIterator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
|
||||||
|
template<>
|
||||||
|
struct hash<google::protobuf::MapKey> {
|
||||||
|
size_t
|
||||||
|
operator()(const google::protobuf::MapKey& map_key) const {
|
||||||
|
switch (map_key.type()) {
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
|
||||||
|
GOOGLE_LOG(FATAL) << "Unsupported";
|
||||||
|
break;
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
|
||||||
|
return hash<string>()(map_key.GetStringValue());
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
|
||||||
|
return hash< ::google::protobuf::int64>()(map_key.GetInt64Value());
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
|
||||||
|
return hash< ::google::protobuf::int32>()(map_key.GetInt32Value());
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
|
||||||
|
return hash< ::google::protobuf::uint64>()(map_key.GetUInt64Value());
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
|
||||||
|
return hash< ::google::protobuf::uint32>()(map_key.GetUInt32Value());
|
||||||
|
case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
|
||||||
|
return hash<bool>()(map_key.GetBoolValue());
|
||||||
|
}
|
||||||
|
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bool
|
||||||
|
operator()(const google::protobuf::MapKey& map_key1,
|
||||||
|
const google::protobuf::MapKey& map_key2) const {
|
||||||
|
return map_key1 < map_key2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
|
||||||
|
|
||||||
#endif // GOOGLE_PROTOBUF_MAP_FIELD_H__
|
#endif // GOOGLE_PROTOBUF_MAP_FIELD_H__
|
||||||
|
|||||||
+80
-228
@@ -162,81 +162,32 @@ void TypeDefinedMapFieldBase<Key, T>::CopyIterator(
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField()
|
default_enum_value>::size() const {
|
||||||
: default_entry_(NULL) {}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(
|
|
||||||
Arena* arena)
|
|
||||||
: TypeDefinedMapFieldBase<Key, T>(arena),
|
|
||||||
MapFieldLite<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(
|
|
||||||
arena),
|
|
||||||
default_entry_(NULL) {}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(
|
|
||||||
const Message* default_entry)
|
|
||||||
: default_entry_(down_cast<const EntryType*>(default_entry)) {}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(
|
|
||||||
Arena* arena, const Message* default_entry)
|
|
||||||
: TypeDefinedMapFieldBase<Key, T>(arena),
|
|
||||||
MapFieldLite<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(
|
|
||||||
arena),
|
|
||||||
default_entry_(down_cast<const EntryType*>(default_entry)) {}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::~MapField() {}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
int
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::size() const {
|
|
||||||
MapFieldBase::SyncMapWithRepeatedField();
|
MapFieldBase::SyncMapWithRepeatedField();
|
||||||
return MapFieldLiteType::GetInternalMap().size();
|
return static_cast<int>(impl_.GetMap().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
void
|
default_enum_value>::Clear() {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::Clear() {
|
|
||||||
MapFieldBase::SyncMapWithRepeatedField();
|
MapFieldBase::SyncMapWithRepeatedField();
|
||||||
MapFieldLiteType::MutableInternalMap()->clear();
|
impl_.MutableMap()->clear();
|
||||||
MapFieldBase::SetMapDirty();
|
MapFieldBase::SetMapDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
void MapField<Key, T, kKeyFieldType, kValueFieldType,
|
default_enum_value>::SetMapIteratorValue(MapIterator* map_iter)
|
||||||
default_enum_value>::SetMapIteratorValue(
|
const {
|
||||||
MapIterator* map_iter) const {
|
const Map<Key, T>& map = impl_.GetMap();
|
||||||
const Map<Key, T>& map = GetMap();
|
|
||||||
typename Map<Key, T>::const_iterator iter =
|
typename Map<Key, T>::const_iterator iter =
|
||||||
TypeDefinedMapFieldBase<Key, T>::InternalGetIterator(map_iter);
|
TypeDefinedMapFieldBase<Key, T>::InternalGetIterator(map_iter);
|
||||||
if (iter == map.end()) return;
|
if (iter == map.end()) return;
|
||||||
@@ -244,27 +195,23 @@ void MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|||||||
map_iter->value_.SetValue(&iter->second);
|
map_iter->value_.SetValue(&iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
bool MapField<Key, T, kKeyFieldType, kValueFieldType,
|
default_enum_value>::ContainsMapKey(const MapKey& map_key) const {
|
||||||
default_enum_value>::ContainsMapKey(
|
const Map<Key, T>& map = impl_.GetMap();
|
||||||
const MapKey& map_key) const {
|
|
||||||
const Map<Key, T>& map = GetMap();
|
|
||||||
const Key& key = UnwrapMapKey<Key>(map_key);
|
const Key& key = UnwrapMapKey<Key>(map_key);
|
||||||
typename Map<Key, T>::const_iterator iter = map.find(key);
|
typename Map<Key, T>::const_iterator iter = map.find(key);
|
||||||
return iter != map.end();
|
return iter != map.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
bool MapField<Key, T, kKeyFieldType, kValueFieldType,
|
default_enum_value>::InsertOrLookupMapValue(const MapKey& map_key,
|
||||||
default_enum_value>::InsertOrLookupMapValue(
|
MapValueRef* val) {
|
||||||
const MapKey& map_key,
|
|
||||||
MapValueRef* val) {
|
|
||||||
// Always use mutable map because users may change the map value by
|
// Always use mutable map because users may change the map value by
|
||||||
// MapValueRef.
|
// MapValueRef.
|
||||||
Map<Key, T>* map = MutableMap();
|
Map<Key, T>* map = MutableMap();
|
||||||
@@ -280,158 +227,83 @@ bool MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
bool MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
bool MapField<Key, T, kKeyFieldType, kValueFieldType,
|
default_enum_value>::DeleteMapValue(const MapKey& map_key) {
|
||||||
default_enum_value>::DeleteMapValue(
|
|
||||||
const MapKey& map_key) {
|
|
||||||
const Key& key = UnwrapMapKey<Key>(map_key);
|
const Key& key = UnwrapMapKey<Key>(map_key);
|
||||||
return MutableMap()->erase(key);
|
return MutableMap()->erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
const Map<Key, T>&
|
default_enum_value>::MergeFrom(const MapField& other) {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::GetMap() const {
|
|
||||||
MapFieldBase::SyncMapWithRepeatedField();
|
MapFieldBase::SyncMapWithRepeatedField();
|
||||||
return MapFieldLiteType::GetInternalMap();
|
other.SyncMapWithRepeatedField();
|
||||||
}
|
impl_.MergeFrom(other.impl_);
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
Map<Key, T>*
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::MutableMap() {
|
|
||||||
MapFieldBase::SyncMapWithRepeatedField();
|
|
||||||
Map<Key, T>* result = MapFieldLiteType::MutableInternalMap();
|
|
||||||
MapFieldBase::SetMapDirty();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::MergeFrom(
|
|
||||||
const MapFieldLiteType& other) {
|
|
||||||
const MapField& down_other = down_cast<const MapField&>(other);
|
|
||||||
MapFieldBase::SyncMapWithRepeatedField();
|
|
||||||
down_other.SyncMapWithRepeatedField();
|
|
||||||
MapFieldLiteType::MergeFrom(other);
|
|
||||||
MapFieldBase::SetMapDirty();
|
MapFieldBase::SetMapDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
void
|
default_enum_value>::Swap(MapField* other) {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
std::swap(this->MapFieldBase::repeated_field_, other->repeated_field_);
|
||||||
default_enum_value>::Swap(
|
impl_.Swap(&other->impl_);
|
||||||
MapFieldLiteType* other) {
|
std::swap(this->MapFieldBase::state_, other->state_);
|
||||||
MapField* down_other = down_cast<MapField*>(other);
|
|
||||||
std::swap(MapFieldBase::repeated_field_, down_other->repeated_field_);
|
|
||||||
MapFieldLiteType::Swap(other);
|
|
||||||
std::swap(MapFieldBase::state_, down_other->state_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
void
|
default_enum_value>::SyncRepeatedFieldWithMapNoLock() const {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
if (this->MapFieldBase::repeated_field_ == NULL) {
|
||||||
default_enum_value>::SetEntryDescriptor(
|
if (this->MapFieldBase::arena_ == NULL) {
|
||||||
const Descriptor** descriptor) {
|
this->MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>();
|
||||||
MapFieldBase::entry_descriptor_ = descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::SetAssignDescriptorCallback(void (*callback)()) {
|
|
||||||
MapFieldBase::assign_descriptor_callback_ = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
const Map<Key, T>&
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::GetInternalMap() const {
|
|
||||||
return MapFieldLiteType::GetInternalMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
Map<Key, T>*
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::MutableInternalMap() {
|
|
||||||
return MapFieldLiteType::MutableInternalMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::SyncRepeatedFieldWithMapNoLock() const {
|
|
||||||
if (MapFieldBase::repeated_field_ == NULL) {
|
|
||||||
if (MapFieldBase::arena_ == NULL) {
|
|
||||||
MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>();
|
|
||||||
} else {
|
} else {
|
||||||
MapFieldBase::repeated_field_ =
|
this->MapFieldBase::repeated_field_ =
|
||||||
Arena::CreateMessage<RepeatedPtrField<Message> >(
|
Arena::CreateMessage<RepeatedPtrField<Message> >(
|
||||||
MapFieldBase::arena_);
|
this->MapFieldBase::arena_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const Map<Key, T>& map = GetInternalMap();
|
const Map<Key, T>& map = impl_.GetMap();
|
||||||
RepeatedPtrField<EntryType>* repeated_field =
|
RepeatedPtrField<EntryType>* repeated_field =
|
||||||
reinterpret_cast<RepeatedPtrField<EntryType>*>(
|
reinterpret_cast<RepeatedPtrField<EntryType>*>(
|
||||||
MapFieldBase::repeated_field_);
|
this->MapFieldBase::repeated_field_);
|
||||||
|
|
||||||
repeated_field->Clear();
|
repeated_field->Clear();
|
||||||
|
|
||||||
|
// The only way we can get at this point is through reflection and the
|
||||||
|
// only way we can get the reflection object is by having called GetReflection
|
||||||
|
// on the encompassing field. So that type must have existed and hence we
|
||||||
|
// know that this MapEntry default_type has also already been constructed.
|
||||||
|
// So it's safe to just call internal_default_instance().
|
||||||
|
const Message* default_entry = Derived::internal_default_instance();
|
||||||
for (typename Map<Key, T>::const_iterator it = map.begin();
|
for (typename Map<Key, T>::const_iterator it = map.begin();
|
||||||
it != map.end(); ++it) {
|
it != map.end(); ++it) {
|
||||||
InitDefaultEntryOnce();
|
|
||||||
GOOGLE_CHECK(default_entry_ != NULL);
|
|
||||||
EntryType* new_entry =
|
EntryType* new_entry =
|
||||||
down_cast<EntryType*>(default_entry_->New(MapFieldBase::arena_));
|
down_cast<EntryType*>(default_entry->New(this->MapFieldBase::arena_));
|
||||||
repeated_field->AddAllocated(new_entry);
|
repeated_field->AddAllocated(new_entry);
|
||||||
(*new_entry->mutable_key()) = it->first;
|
(*new_entry->mutable_key()) = it->first;
|
||||||
(*new_entry->mutable_value()) = it->second;
|
(*new_entry->mutable_value()) = it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
void
|
default_enum_value>::SyncMapWithRepeatedFieldNoLock() const {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
Map<Key, T>* map = const_cast<MapField*>(this)->impl_.MutableMap();
|
||||||
default_enum_value>::SyncMapWithRepeatedFieldNoLock() const {
|
|
||||||
Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap();
|
|
||||||
RepeatedPtrField<EntryType>* repeated_field =
|
RepeatedPtrField<EntryType>* repeated_field =
|
||||||
reinterpret_cast<RepeatedPtrField<EntryType>*>(
|
reinterpret_cast<RepeatedPtrField<EntryType>*>(
|
||||||
MapFieldBase::repeated_field_);
|
this->MapFieldBase::repeated_field_);
|
||||||
GOOGLE_CHECK(MapFieldBase::repeated_field_ != NULL);
|
GOOGLE_CHECK(this->MapFieldBase::repeated_field_ != NULL);
|
||||||
map->clear();
|
map->clear();
|
||||||
for (typename RepeatedPtrField<EntryType>::iterator it =
|
for (typename RepeatedPtrField<EntryType>::iterator it =
|
||||||
repeated_field->begin(); it != repeated_field->end(); ++it) {
|
repeated_field->begin(); it != repeated_field->end(); ++it) {
|
||||||
@@ -444,44 +316,24 @@ MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
int default_enum_value>
|
size_t MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
||||||
int
|
default_enum_value>::SpaceUsedExcludingSelfNoLock() const {
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
size_t size = 0;
|
||||||
default_enum_value>::SpaceUsedExcludingSelfNoLock() const {
|
if (this->MapFieldBase::repeated_field_ != NULL) {
|
||||||
int size = 0;
|
size += this->MapFieldBase::repeated_field_->SpaceUsedExcludingSelfLong();
|
||||||
if (MapFieldBase::repeated_field_ != NULL) {
|
|
||||||
size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf();
|
|
||||||
}
|
}
|
||||||
Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap();
|
Map<Key, T>* map = const_cast<MapField*>(this)->impl_.MutableMap();
|
||||||
size += sizeof(*map);
|
size += sizeof(*map);
|
||||||
for (typename Map<Key, T>::iterator it = map->begin();
|
for (typename Map<Key, T>::iterator it = map->begin(); it != map->end();
|
||||||
it != map->end(); ++it) {
|
++it) {
|
||||||
size += KeyTypeHandler::SpaceUsedInMap(it->first);
|
size += KeyTypeHandler::SpaceUsedInMapLong(it->first);
|
||||||
size += ValueTypeHandler::SpaceUsedInMap(it->second);
|
size += ValueTypeHandler::SpaceUsedInMapLong(it->second);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType kKeyFieldType,
|
|
||||||
WireFormatLite::FieldType kValueFieldType,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapField<Key, T, kKeyFieldType, kValueFieldType,
|
|
||||||
default_enum_value>::InitDefaultEntryOnce()
|
|
||||||
const {
|
|
||||||
if (default_entry_ == NULL) {
|
|
||||||
MapFieldBase::InitMetadataOnce();
|
|
||||||
GOOGLE_CHECK(*MapFieldBase::entry_descriptor_ != NULL);
|
|
||||||
default_entry_ = down_cast<const EntryType*>(
|
|
||||||
MessageFactory::generated_factory()->GetPrototype(
|
|
||||||
*MapFieldBase::entry_descriptor_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|||||||
+59
-194
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <google/protobuf/map.h>
|
#include <google/protobuf/map.h>
|
||||||
#include <google/protobuf/map_entry_lite.h>
|
#include <google/protobuf/map_entry_lite.h>
|
||||||
|
#include <google/protobuf/wire_format_lite.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
@@ -41,223 +42,72 @@ namespace internal {
|
|||||||
// This class provides access to map field using generated api. It is used for
|
// This class provides access to map field using generated api. It is used for
|
||||||
// internal generated message implentation only. Users should never use this
|
// internal generated message implentation only. Users should never use this
|
||||||
// directly.
|
// directly.
|
||||||
template <typename Key, typename T,
|
template <typename Derived, typename Key, typename T,
|
||||||
WireFormatLite::FieldType key_wire_type,
|
WireFormatLite::FieldType key_wire_type,
|
||||||
WireFormatLite::FieldType value_wire_type,
|
WireFormatLite::FieldType value_wire_type, int default_enum_value = 0>
|
||||||
int default_enum_value = 0>
|
|
||||||
class MapFieldLite {
|
class MapFieldLite {
|
||||||
// Define message type for internal repeated field.
|
// Define message type for internal repeated field.
|
||||||
typedef MapEntryLite<Key, T, key_wire_type, value_wire_type,
|
typedef Derived EntryType;
|
||||||
default_enum_value> EntryType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapFieldLite();
|
typedef Map<Key, T> MapType;
|
||||||
explicit MapFieldLite(Arena* arena);
|
typedef EntryType EntryTypeTrait;
|
||||||
virtual ~MapFieldLite();
|
|
||||||
|
MapFieldLite() : arena_(NULL) { SetDefaultEnumValue(); }
|
||||||
|
|
||||||
|
explicit MapFieldLite(Arena* arena) : arena_(arena), map_(arena) {
|
||||||
|
SetDefaultEnumValue();
|
||||||
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
virtual const Map<Key, T>& GetMap() const;
|
const Map<Key, T>& GetMap() const { return map_; }
|
||||||
virtual Map<Key, T>* MutableMap();
|
Map<Key, T>* MutableMap() { return &map_; }
|
||||||
|
|
||||||
// Convenient methods for generated message implementation.
|
// Convenient methods for generated message implementation.
|
||||||
virtual int size() const;
|
int size() const { return static_cast<int>(map_.size()); }
|
||||||
virtual void Clear();
|
void Clear() { return map_.clear(); }
|
||||||
virtual void MergeFrom(const MapFieldLite& other);
|
void MergeFrom(const MapFieldLite& other) {
|
||||||
virtual void Swap(MapFieldLite* other);
|
for (typename Map<Key, T>::const_iterator it = other.map_.begin();
|
||||||
|
it != other.map_.end(); ++it) {
|
||||||
|
map_[it->first] = it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Swap(MapFieldLite* other) { map_.swap(other->map_); }
|
||||||
|
|
||||||
// Set default enum value only for proto2 map field whose value is enum type.
|
// Set default enum value only for proto2 map field whose value is enum type.
|
||||||
void SetDefaultEnumValue();
|
void SetDefaultEnumValue() {
|
||||||
|
MutableMap()->SetDefaultEnumValue(default_enum_value);
|
||||||
|
}
|
||||||
|
|
||||||
// Used in the implementation of parsing. Caller should take the ownership.
|
// Used in the implementation of parsing. Caller should take the ownership iff
|
||||||
EntryType* NewEntry() const;
|
// arena_ is NULL.
|
||||||
|
EntryType* NewEntry() const {
|
||||||
|
if (arena_ == NULL) {
|
||||||
|
return new EntryType();
|
||||||
|
} else {
|
||||||
|
return Arena::CreateMessage<EntryType>(arena_);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Used in the implementation of serializing enum value type. Caller should
|
// Used in the implementation of serializing enum value type. Caller should
|
||||||
// take the ownership.
|
// take the ownership iff arena_ is NULL.
|
||||||
EntryType* NewEnumEntryWrapper(const Key& key, const T t) const;
|
EntryType* NewEnumEntryWrapper(const Key& key, const T t) const {
|
||||||
|
return EntryType::EnumWrap(key, t, arena_);
|
||||||
|
}
|
||||||
// Used in the implementation of serializing other value types. Caller should
|
// Used in the implementation of serializing other value types. Caller should
|
||||||
// take the ownership.
|
// take the ownership iff arena_ is NULL.
|
||||||
EntryType* NewEntryWrapper(const Key& key, const T& t) const;
|
EntryType* NewEntryWrapper(const Key& key, const T& t) const {
|
||||||
|
return EntryType::Wrap(key, t, arena_);
|
||||||
protected:
|
}
|
||||||
// Convenient methods to get internal google::protobuf::Map
|
|
||||||
virtual const Map<Key, T>& GetInternalMap() const;
|
|
||||||
virtual Map<Key, T>* MutableInternalMap();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
|
|
||||||
Arena* arena_;
|
Arena* arena_;
|
||||||
Map<Key, T>* map_;
|
Map<Key, T> map_;
|
||||||
|
|
||||||
friend class ::google::protobuf::Arena;
|
friend class ::google::protobuf::Arena;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::MapFieldLite()
|
|
||||||
: arena_(NULL) {
|
|
||||||
map_ = new Map<Key, T>;
|
|
||||||
SetDefaultEnumValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::MapFieldLite(Arena* arena)
|
|
||||||
: arena_(arena) {
|
|
||||||
map_ = Arena::CreateMessage<Map<Key, T> >(arena);
|
|
||||||
SetDefaultEnumValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::~MapFieldLite() {
|
|
||||||
delete map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
const Map<Key, T>&
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::GetMap() const {
|
|
||||||
return *map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
Map<Key, T>*
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::MutableMap() {
|
|
||||||
return map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
int
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::size() const {
|
|
||||||
return map_->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::Clear() {
|
|
||||||
map_->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::MergeFrom(
|
|
||||||
const MapFieldLite& other) {
|
|
||||||
for (typename Map<Key, T>::const_iterator it = other.map_->begin();
|
|
||||||
it != other.map_->end(); ++it) {
|
|
||||||
(*map_)[it->first] = it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::Swap(
|
|
||||||
MapFieldLite* other) {
|
|
||||||
std::swap(map_, other->map_);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
void
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::SetDefaultEnumValue() {
|
|
||||||
MutableInternalMap()->SetDefaultEnumValue(default_enum_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
const Map<Key, T>&
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::GetInternalMap() const {
|
|
||||||
return *map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
Map<Key, T>*
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::MutableInternalMap() {
|
|
||||||
return map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EntryType \
|
|
||||||
MapEntryLite<Key, T, key_wire_type, value_wire_type, default_enum_value>
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
EntryType*
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::NewEntry() const {
|
|
||||||
if (arena_ == NULL) {
|
|
||||||
return new EntryType();
|
|
||||||
} else {
|
|
||||||
return Arena::CreateMessage<EntryType>(arena_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
EntryType*
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::NewEnumEntryWrapper(const Key& key,
|
|
||||||
const T t) const {
|
|
||||||
return EntryType::EnumWrap(key, t, arena_);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Key, typename T,
|
|
||||||
WireFormatLite::FieldType key_wire_type,
|
|
||||||
WireFormatLite::FieldType value_wire_type,
|
|
||||||
int default_enum_value>
|
|
||||||
EntryType*
|
|
||||||
MapFieldLite<Key, T, key_wire_type, value_wire_type,
|
|
||||||
default_enum_value>::NewEntryWrapper(const Key& key,
|
|
||||||
const T& t) const {
|
|
||||||
return EntryType::Wrap(key, t, arena_);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef EntryType
|
|
||||||
|
|
||||||
// True if IsInitialized() is true for value field in all elements of t. T is
|
// True if IsInitialized() is true for value field in all elements of t. T is
|
||||||
// expected to be message. It's useful to have this helper here to keep the
|
// expected to be message. It's useful to have this helper here to keep the
|
||||||
// protobuf compiler from ever having to emit loops in IsInitialized() methods.
|
// protobuf compiler from ever having to emit loops in IsInitialized() methods.
|
||||||
@@ -271,6 +121,21 @@ bool AllAreInitialized(const Map<Key, T>& t) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename MEntry>
|
||||||
|
struct MapEntryToMapField : MapEntryToMapField<typename MEntry::SuperType> {};
|
||||||
|
|
||||||
|
template <typename T, typename Key, typename Value,
|
||||||
|
WireFormatLite::FieldType kKeyFieldType,
|
||||||
|
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
|
||||||
|
struct MapEntryToMapField<MapEntryLite<T, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value> > {
|
||||||
|
typedef MapFieldLite<MapEntryLite<T, Key, Value, kKeyFieldType,
|
||||||
|
kValueFieldType, default_enum_value>,
|
||||||
|
Key, Value, kKeyFieldType, kValueFieldType,
|
||||||
|
default_enum_value>
|
||||||
|
MapFieldType;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
|
|||||||
+73
-77
@@ -32,7 +32,6 @@
|
|||||||
#define GOOGLE_PROTOBUF_TYPE_HANDLER_H__
|
#define GOOGLE_PROTOBUF_TYPE_HANDLER_H__
|
||||||
|
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
#include <google/protobuf/wire_format_lite_inl.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
@@ -73,7 +72,7 @@ class MapValueInitializer<true, Type> {
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
class MapValueInitializer<false, Type> {
|
class MapValueInitializer<false, Type> {
|
||||||
public:
|
public:
|
||||||
static inline void Initialize(Type& value, int default_enum_value) {}
|
static inline void Initialize(Type& /* value */, int /* default_enum_value */) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type, bool is_arena_constructable>
|
template <typename Type, bool is_arena_constructable>
|
||||||
@@ -186,9 +185,9 @@ class MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> {
|
|||||||
static inline Type* EnsureMutable(Type** value, Arena* arena);
|
static inline Type* EnsureMutable(Type** value, Arena* arena);
|
||||||
// SpaceUsedInMapEntry: Return bytes used by value in MapEntry, excluding
|
// SpaceUsedInMapEntry: Return bytes used by value in MapEntry, excluding
|
||||||
// those already calculate in sizeof(MapField).
|
// those already calculate in sizeof(MapField).
|
||||||
static inline int SpaceUsedInMapEntry(const Type* value);
|
static inline size_t SpaceUsedInMapEntryLong(const Type* value);
|
||||||
// Return bytes used by value in Map.
|
// Return bytes used by value in Map.
|
||||||
static inline int SpaceUsedInMap(const Type& value);
|
static inline size_t SpaceUsedInMapLong(const Type& value);
|
||||||
// Assign default value to given instance.
|
// Assign default value to given instance.
|
||||||
static inline void AssignDefaultValue(Type** value);
|
static inline void AssignDefaultValue(Type** value);
|
||||||
// Return default instance if value is not initialized when calling const
|
// Return default instance if value is not initialized when calling const
|
||||||
@@ -224,9 +223,7 @@ class MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> {
|
|||||||
static inline void Write(int field, const MapEntryAccessorType& value, \
|
static inline void Write(int field, const MapEntryAccessorType& value, \
|
||||||
io::CodedOutputStream* output); \
|
io::CodedOutputStream* output); \
|
||||||
static inline uint8* InternalWriteToArray( \
|
static inline uint8* InternalWriteToArray( \
|
||||||
int field, \
|
int field, const MapEntryAccessorType& value, bool deterministic, \
|
||||||
const MapEntryAccessorType& value, \
|
|
||||||
bool deterministic, \
|
|
||||||
uint8* target); \
|
uint8* target); \
|
||||||
static inline uint8* WriteToArray(int field, \
|
static inline uint8* WriteToArray(int field, \
|
||||||
const MapEntryAccessorType& value, \
|
const MapEntryAccessorType& value, \
|
||||||
@@ -242,9 +239,9 @@ class MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> {
|
|||||||
static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \
|
static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \
|
||||||
Arena* arena, \
|
Arena* arena, \
|
||||||
int default_enum); \
|
int default_enum); \
|
||||||
static inline int SpaceUsedInMapEntry(const TypeOnMemory& value); \
|
static inline size_t SpaceUsedInMapEntryLong(const TypeOnMemory& value); \
|
||||||
static inline int SpaceUsedInMap(const TypeOnMemory& value); \
|
static inline size_t SpaceUsedInMapLong(const TypeOnMemory& value); \
|
||||||
static inline int SpaceUsedInMap(const string& value); \
|
static inline size_t SpaceUsedInMapLong(const string& value); \
|
||||||
static inline void AssignDefaultValue(TypeOnMemory* value); \
|
static inline void AssignDefaultValue(TypeOnMemory* value); \
|
||||||
static inline const MapEntryAccessorType& DefaultIfNotInitialized( \
|
static inline const MapEntryAccessorType& DefaultIfNotInitialized( \
|
||||||
const TypeOnMemory& value, const TypeOnMemory& default_value); \
|
const TypeOnMemory& value, const TypeOnMemory& default_value); \
|
||||||
@@ -286,7 +283,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize(
|
|||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
|
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
|
||||||
const MapEntryAccessorType& value) { \
|
const MapEntryAccessorType& value) { \
|
||||||
return WireFormatLite::DeclaredType##Size(value); \
|
return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_BYTE_SIZE(STRING, String)
|
GOOGLE_PROTOBUF_BYTE_SIZE(STRING, String)
|
||||||
@@ -304,7 +301,7 @@ GOOGLE_PROTOBUF_BYTE_SIZE(ENUM , Enum)
|
|||||||
#define FIXED_BYTE_SIZE(FieldType, DeclaredType) \
|
#define FIXED_BYTE_SIZE(FieldType, DeclaredType) \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
|
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
|
||||||
const MapEntryAccessorType& value) { \
|
const MapEntryAccessorType& /* value */) { \
|
||||||
return WireFormatLite::k##DeclaredType##Size; \
|
return WireFormatLite::k##DeclaredType##Size; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +319,9 @@ template <typename Type>
|
|||||||
inline int
|
inline int
|
||||||
MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(
|
MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(
|
||||||
const MapEntryAccessorType& value) {
|
const MapEntryAccessorType& value) {
|
||||||
return WireFormatLite::LengthDelimitedSize(value.GetCachedSize());
|
return static_cast<int>(
|
||||||
|
WireFormatLite::LengthDelimitedSize(
|
||||||
|
static_cast<size_t>(value.GetCachedSize())));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_CACHED_SIZE(FieldType, DeclaredType) \
|
#define GET_CACHED_SIZE(FieldType, DeclaredType) \
|
||||||
@@ -330,7 +329,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(
|
|||||||
inline int \
|
inline int \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \
|
||||||
const MapEntryAccessorType& value) { \
|
const MapEntryAccessorType& value) { \
|
||||||
return WireFormatLite::DeclaredType##Size(value); \
|
return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_CACHED_SIZE(STRING, String)
|
GET_CACHED_SIZE(STRING, String)
|
||||||
@@ -349,7 +348,7 @@ GET_CACHED_SIZE(ENUM , Enum)
|
|||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int \
|
inline int \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \
|
||||||
const MapEntryAccessorType& value) { \
|
const MapEntryAccessorType& /* value */) { \
|
||||||
return WireFormatLite::k##DeclaredType##Size; \
|
return WireFormatLite::k##DeclaredType##Size; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,34 +466,33 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline int
|
inline size_t MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
||||||
MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
Type>::SpaceUsedInMapEntryLong(const Type* value) {
|
||||||
Type>::SpaceUsedInMapEntry(const Type* value) {
|
return value->SpaceUsedLong();
|
||||||
return value->SpaceUsed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
int MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::SpaceUsedInMap(
|
size_t MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::SpaceUsedInMapLong(
|
||||||
const Type& value) {
|
const Type& value) {
|
||||||
return value.SpaceUsed();
|
return value.SpaceUsedLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Clear(
|
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Clear(
|
||||||
Type** value, Arena* arena) {
|
Type** value, Arena* /* arena */) {
|
||||||
if (*value != NULL) (*value)->Clear();
|
if (*value != NULL) (*value)->Clear();
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void
|
inline void
|
||||||
MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
||||||
Type>::ClearMaybeByDefaultEnum(Type** value,
|
Type>::ClearMaybeByDefaultEnum(Type** value,
|
||||||
Arena* arena,
|
Arena* /* arena */,
|
||||||
int default_enum_value) {
|
int /* default_enum_value */) {
|
||||||
if (*value != NULL) (*value)->Clear();
|
if (*value != NULL) (*value)->Clear();
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Merge(
|
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Merge(
|
||||||
const Type& from, Type** to, Arena* arena) {
|
const Type& from, Type** to, Arena* /* arena */) {
|
||||||
(*to)->MergeFrom(from);
|
(*to)->MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,20 +505,20 @@ void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::DeleteNoArena(
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
||||||
Type>::AssignDefaultValue(Type** value) {
|
Type>::AssignDefaultValue(Type** value) {
|
||||||
*value = const_cast<Type*>(&Type::default_instance());
|
*value = const_cast<Type*>(Type::internal_default_instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
||||||
Type>::Initialize(Type** x,
|
Type>::Initialize(Type** x,
|
||||||
Arena* arena) {
|
Arena* /* arena */) {
|
||||||
*x = NULL;
|
*x = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::
|
inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::
|
||||||
InitializeMaybeByDefaultEnum(Type** x, int default_enum_value,
|
InitializeMaybeByDefaultEnum(Type** x, int /* default_enum_value */,
|
||||||
Arena* arena) {
|
Arena* /* arena */) {
|
||||||
*x = NULL;
|
*x = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,22 +554,24 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
|||||||
Type>::MapEntryAccessorType& \
|
Type>::MapEntryAccessorType& \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::GetExternalReference(const TypeOnMemory& value) { \
|
Type>::GetExternalReference(const TypeOnMemory& value) { \
|
||||||
return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
|
return value.Get(); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int \
|
inline size_t \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
|
Type>::SpaceUsedInMapEntryLong(const TypeOnMemory& value) { \
|
||||||
|
return sizeof(value); \
|
||||||
|
} \
|
||||||
|
template <typename Type> \
|
||||||
|
inline size_t \
|
||||||
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \
|
||||||
const TypeOnMemory& value) { \
|
const TypeOnMemory& value) { \
|
||||||
return sizeof(value); \
|
return sizeof(value); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline size_t \
|
||||||
Type>::SpaceUsedInMap(const TypeOnMemory& value) { \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \
|
||||||
return sizeof(value); \
|
const string& value) { \
|
||||||
} \
|
|
||||||
template <typename Type> \
|
|
||||||
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
|
||||||
Type>::SpaceUsedInMap(const string& value) { \
|
|
||||||
return sizeof(value); \
|
return sizeof(value); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
@@ -581,11 +581,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
|||||||
arena); \
|
arena); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \
|
||||||
Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \
|
int /* default_enum */) { \
|
||||||
Arena* arena, \
|
|
||||||
int default_enum) { \
|
|
||||||
Clear(value, arena); \
|
Clear(value, arena); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
@@ -600,20 +598,19 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
|||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::AssignDefaultValue(TypeOnMemory* value) {} \
|
Type>::AssignDefaultValue(TypeOnMemory* /* value */) {} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \
|
||||||
TypeOnMemory* value, Arena* arena) { \
|
TypeOnMemory* value, Arena* /* arena */) { \
|
||||||
value->UnsafeSetDefault( \
|
value->UnsafeSetDefault( \
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
|
||||||
Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
|
int /* default_enum_value */, \
|
||||||
int default_enum_value, \
|
Arena* arena) { \
|
||||||
Arena* arena) { \
|
|
||||||
Initialize(value, arena); \
|
Initialize(value, arena); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
@@ -630,12 +627,12 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
|
|||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
|
Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
|
||||||
const TypeOnMemory& \
|
const TypeOnMemory& \
|
||||||
default_value) { \
|
/* default_value */) { \
|
||||||
return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
|
return value.Get(); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::IsInitialized(const TypeOnMemory& value) { \
|
Type>::IsInitialized(const TypeOnMemory& /* value */) { \
|
||||||
return true; \
|
return true; \
|
||||||
}
|
}
|
||||||
STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING)
|
STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING)
|
||||||
@@ -651,59 +648,58 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES)
|
|||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int \
|
inline size_t \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
const TypeOnMemory& value) { \
|
Type>::SpaceUsedInMapEntryLong(const TypeOnMemory& /* value */) { \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline size_t \
|
||||||
Type>::SpaceUsedInMap(const TypeOnMemory& value) { \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapLong( \
|
||||||
|
const TypeOnMemory& /* value */) { \
|
||||||
return sizeof(Type); \
|
return sizeof(Type); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \
|
||||||
TypeOnMemory* value, Arena* arena) { \
|
TypeOnMemory* value, Arena* /* arena */) { \
|
||||||
*value = 0; \
|
*value = 0; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* /* arena */, \
|
||||||
Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \
|
int default_enum_value) { \
|
||||||
Arena* arena, \
|
|
||||||
int default_enum_value) { \
|
|
||||||
*value = static_cast<TypeOnMemory>(default_enum_value); \
|
*value = static_cast<TypeOnMemory>(default_enum_value); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \
|
||||||
const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \
|
const MapEntryAccessorType& from, TypeOnMemory* to, \
|
||||||
|
Arena* /* arena */) { \
|
||||||
*to = from; \
|
*to = from; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::DeleteNoArena(TypeOnMemory& x) {} \
|
Type>::DeleteNoArena(TypeOnMemory& /* x */) {} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::AssignDefaultValue(TypeOnMemory* value) {} \
|
Type>::AssignDefaultValue(TypeOnMemory* /* value */) {} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \
|
||||||
TypeOnMemory* value, Arena* arena) { \
|
TypeOnMemory* value, Arena* /* arena */) { \
|
||||||
*value = 0; \
|
*value = 0; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline void \
|
inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
|
||||||
Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
|
int default_enum_value, \
|
||||||
int default_enum_value, \
|
Arena* /* arena */) { \
|
||||||
Arena* arena) { \
|
|
||||||
*value = static_cast<TypeOnMemory>(default_enum_value); \
|
*value = static_cast<TypeOnMemory>(default_enum_value); \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::MapEntryAccessorType* \
|
Type>::MapEntryAccessorType* \
|
||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
|
||||||
TypeOnMemory* value, Arena* arena) { \
|
TypeOnMemory* value, Arena* /* arena */) { \
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
@@ -712,12 +708,12 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES)
|
|||||||
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
|
Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
|
||||||
const TypeOnMemory& \
|
const TypeOnMemory& \
|
||||||
default_value) { \
|
/* default_value */) { \
|
||||||
return value; \
|
return value; \
|
||||||
} \
|
} \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
|
||||||
Type>::IsInitialized(const TypeOnMemory& value) { \
|
Type>::IsInitialized(const TypeOnMemory& /* value */) { \
|
||||||
return true; \
|
return true; \
|
||||||
}
|
}
|
||||||
PRIMITIVE_HANDLER_FUNCTIONS(INT64)
|
PRIMITIVE_HANDLER_FUNCTIONS(INT64)
|
||||||
|
|||||||
+30
-52
@@ -96,12 +96,12 @@ bool Message::IsInitialized() const {
|
|||||||
return ReflectionOps::IsInitialized(*this);
|
return ReflectionOps::IsInitialized(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Message::FindInitializationErrors(vector<string>* errors) const {
|
void Message::FindInitializationErrors(std::vector<string>* errors) const {
|
||||||
return ReflectionOps::FindInitializationErrors(*this, "", errors);
|
return ReflectionOps::FindInitializationErrors(*this, "", errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
string Message::InitializationErrorString() const {
|
string Message::InitializationErrorString() const {
|
||||||
vector<string> errors;
|
std::vector<string> errors;
|
||||||
FindInitializationErrors(&errors);
|
FindInitializationErrors(&errors);
|
||||||
return Join(errors, ", ");
|
return Join(errors, ", ");
|
||||||
}
|
}
|
||||||
@@ -130,12 +130,12 @@ bool Message::ParsePartialFromFileDescriptor(int file_descriptor) {
|
|||||||
return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0;
|
return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::ParseFromIstream(istream* input) {
|
bool Message::ParseFromIstream(std::istream* input) {
|
||||||
io::IstreamInputStream zero_copy_input(input);
|
io::IstreamInputStream zero_copy_input(input);
|
||||||
return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
|
return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::ParsePartialFromIstream(istream* input) {
|
bool Message::ParsePartialFromIstream(std::istream* input) {
|
||||||
io::IstreamInputStream zero_copy_input(input);
|
io::IstreamInputStream zero_copy_input(input);
|
||||||
return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
|
return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,13 @@ bool Message::ParsePartialFromIstream(istream* input) {
|
|||||||
|
|
||||||
void Message::SerializeWithCachedSizes(
|
void Message::SerializeWithCachedSizes(
|
||||||
io::CodedOutputStream* output) const {
|
io::CodedOutputStream* output) const {
|
||||||
WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output);
|
const internal::SerializationTable* table =
|
||||||
|
static_cast<const internal::SerializationTable*>(InternalGetTable());
|
||||||
|
if (table == 0) {
|
||||||
|
WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output);
|
||||||
|
} else {
|
||||||
|
internal::TableSerialize(*this, table, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Message::ByteSizeLong() const {
|
size_t Message::ByteSizeLong() const {
|
||||||
@@ -158,21 +164,21 @@ void Message::SetCachedSize(int /* size */) const {
|
|||||||
"Must implement one or the other.";
|
"Must implement one or the other.";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Message::SpaceUsed() const {
|
size_t Message::SpaceUsedLong() const {
|
||||||
return GetReflection()->SpaceUsed(*this);
|
return GetReflection()->SpaceUsedLong(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::SerializeToFileDescriptor(int file_descriptor) const {
|
bool Message::SerializeToFileDescriptor(int file_descriptor) const {
|
||||||
io::FileOutputStream output(file_descriptor);
|
io::FileOutputStream output(file_descriptor);
|
||||||
return SerializeToZeroCopyStream(&output);
|
return SerializeToZeroCopyStream(&output) && output.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
|
bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
|
||||||
io::FileOutputStream output(file_descriptor);
|
io::FileOutputStream output(file_descriptor);
|
||||||
return SerializePartialToZeroCopyStream(&output);
|
return SerializePartialToZeroCopyStream(&output) && output.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::SerializeToOstream(ostream* output) const {
|
bool Message::SerializeToOstream(std::ostream* output) const {
|
||||||
{
|
{
|
||||||
io::OstreamOutputStream zero_copy_output(output);
|
io::OstreamOutputStream zero_copy_output(output);
|
||||||
if (!SerializeToZeroCopyStream(&zero_copy_output)) return false;
|
if (!SerializeToZeroCopyStream(&zero_copy_output)) return false;
|
||||||
@@ -180,7 +186,7 @@ bool Message::SerializeToOstream(ostream* output) const {
|
|||||||
return output->good();
|
return output->good();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::SerializePartialToOstream(ostream* output) const {
|
bool Message::SerializePartialToOstream(std::ostream* output) const {
|
||||||
io::OstreamOutputStream zero_copy_output(output);
|
io::OstreamOutputStream zero_copy_output(output);
|
||||||
return SerializePartialToZeroCopyStream(&zero_copy_output);
|
return SerializePartialToZeroCopyStream(&zero_copy_output);
|
||||||
}
|
}
|
||||||
@@ -191,6 +197,10 @@ bool Message::SerializePartialToOstream(ostream* output) const {
|
|||||||
|
|
||||||
Reflection::~Reflection() {}
|
Reflection::~Reflection() {}
|
||||||
|
|
||||||
|
void Reflection::AddAllocatedMessage(Message* /* message */,
|
||||||
|
const FieldDescriptor* /*field */,
|
||||||
|
Message* /* new_entry */) const {}
|
||||||
|
|
||||||
#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \
|
#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \
|
||||||
template<> \
|
template<> \
|
||||||
const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
|
const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
|
||||||
@@ -225,38 +235,6 @@ void* Reflection::MutableRawRepeatedString(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Default EnumValue API implementations. Real reflection implementations should
|
|
||||||
// override these. However, there are several legacy implementations that do
|
|
||||||
// not, and cannot easily be changed at the same time as the Reflection API, so
|
|
||||||
// we provide these for now.
|
|
||||||
// TODO: Remove these once all Reflection implementations are updated.
|
|
||||||
int Reflection::GetEnumValue(const Message& message,
|
|
||||||
const FieldDescriptor* field) const {
|
|
||||||
GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void Reflection::SetEnumValue(Message* message,
|
|
||||||
const FieldDescriptor* field,
|
|
||||||
int value) const {
|
|
||||||
GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
|
|
||||||
}
|
|
||||||
int Reflection::GetRepeatedEnumValue(
|
|
||||||
const Message& message,
|
|
||||||
const FieldDescriptor* field, int index) const {
|
|
||||||
GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void Reflection::SetRepeatedEnumValue(Message* message,
|
|
||||||
const FieldDescriptor* field, int index,
|
|
||||||
int value) const {
|
|
||||||
GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
|
|
||||||
}
|
|
||||||
void Reflection::AddEnumValue(Message* message,
|
|
||||||
const FieldDescriptor* field,
|
|
||||||
int value) const {
|
|
||||||
GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
|
|
||||||
}
|
|
||||||
|
|
||||||
MapIterator Reflection::MapBegin(
|
MapIterator Reflection::MapBegin(
|
||||||
Message* message,
|
Message* message,
|
||||||
const FieldDescriptor* field) const {
|
const FieldDescriptor* field) const {
|
||||||
@@ -483,27 +461,27 @@ struct ShutdownRepeatedFieldRegister {
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template<>
|
template<>
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
|
||||||
// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240
|
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
#endif
|
#endif
|
||||||
Message* GenericTypeHandler<Message>::NewFromPrototype(
|
Message* GenericTypeHandler<Message>::NewFromPrototype(
|
||||||
const Message* prototype, google::protobuf::Arena* arena) {
|
const Message* prototype, google::protobuf::Arena* arena) {
|
||||||
return prototype->New(arena);
|
return prototype->New(arena);
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
|
||||||
// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240
|
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
#endif
|
#endif
|
||||||
google::protobuf::Arena* GenericTypeHandler<Message>::GetArena(
|
google::protobuf::Arena* GenericTypeHandler<Message>::GetArena(
|
||||||
Message* value) {
|
Message* value) {
|
||||||
return value->GetArena();
|
return value->GetArena();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
|
||||||
// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240
|
// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
#endif
|
#endif
|
||||||
void* GenericTypeHandler<Message>::GetMaybeArenaPointer(
|
void* GenericTypeHandler<Message>::GetMaybeArenaPointer(
|
||||||
Message* value) {
|
Message* value) {
|
||||||
|
|||||||
+63
-43
@@ -154,6 +154,13 @@ class MapReflectionFriend; // scalar_map_container.h
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
class ReflectionOps; // reflection_ops.h
|
||||||
|
class MapKeySorter; // wire_format.cc
|
||||||
|
class WireFormat; // wire_format.h
|
||||||
|
class MapFieldReflectionTest; // map_test.cc
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class RepeatedField; // repeated_field.h
|
class RepeatedField; // repeated_field.h
|
||||||
|
|
||||||
@@ -245,7 +252,10 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
|
|||||||
// using reflection (rather than the generated code implementation for
|
// using reflection (rather than the generated code implementation for
|
||||||
// ByteSize()). Like ByteSize(), its CPU time is linear in the number of
|
// ByteSize()). Like ByteSize(), its CPU time is linear in the number of
|
||||||
// fields defined for the proto.
|
// fields defined for the proto.
|
||||||
virtual int SpaceUsed() const;
|
virtual size_t SpaceUsedLong() const;
|
||||||
|
|
||||||
|
PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceUsedLong() instead")
|
||||||
|
int SpaceUsed() const { return internal::ToIntSize(SpaceUsedLong()); }
|
||||||
|
|
||||||
// Debugging & Testing----------------------------------------------
|
// Debugging & Testing----------------------------------------------
|
||||||
|
|
||||||
@@ -317,18 +327,19 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
|
|||||||
// Typedef for backwards-compatibility.
|
// Typedef for backwards-compatibility.
|
||||||
typedef google::protobuf::Reflection Reflection;
|
typedef google::protobuf::Reflection Reflection;
|
||||||
|
|
||||||
// Get a Descriptor for this message's type. This describes what
|
// Get a non-owning pointer to a Descriptor for this message's type. This
|
||||||
// fields the message contains, the types of those fields, etc.
|
// describes what fields the message contains, the types of those fields, etc.
|
||||||
|
// This object remains property of the Message.
|
||||||
const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; }
|
const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; }
|
||||||
|
|
||||||
// Get the Reflection interface for this Message, which can be used to
|
// Get a non-owning pointer to the Reflection interface for this Message,
|
||||||
// read and modify the fields of the Message dynamically (in other words,
|
// which can be used to read and modify the fields of the Message dynamically
|
||||||
// without knowing the message type at compile time). This object remains
|
// (in other words, without knowing the message type at compile time). This
|
||||||
// property of the Message.
|
// object remains property of the Message.
|
||||||
//
|
//
|
||||||
// This method remains virtual in case a subclass does not implement
|
// This method remains virtual in case a subclass does not implement
|
||||||
// reflection and wants to override the default behavior.
|
// reflection and wants to override the default behavior.
|
||||||
virtual const Reflection* GetReflection() const {
|
virtual const Reflection* GetReflection() const PROTOBUF_FINAL {
|
||||||
return GetMetadata().reflection;
|
return GetMetadata().reflection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +428,12 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0;
|
virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0;
|
||||||
|
|
||||||
// Estimate the amount of memory used by the message object.
|
// Estimate the amount of memory used by the message object.
|
||||||
virtual int SpaceUsed(const Message& message) const = 0;
|
virtual size_t SpaceUsedLong(const Message& message) const = 0;
|
||||||
|
|
||||||
|
PROTOBUF_RUNTIME_DEPRECATED("Please use SpaceUsedLong() instead")
|
||||||
|
int SpaceUsed(const Message& message) const {
|
||||||
|
return internal::ToIntSize(SpaceUsedLong(message));
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the given non-repeated field is set.
|
// Check if the given non-repeated field is set.
|
||||||
virtual bool HasField(const Message& message,
|
virtual bool HasField(const Message& message,
|
||||||
@@ -481,11 +497,14 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
int index1,
|
int index1,
|
||||||
int index2) const = 0;
|
int index2) const = 0;
|
||||||
|
|
||||||
// List all fields of the message which are currently set. This includes
|
// List all fields of the message which are currently set, except for unknown
|
||||||
// extensions. Singular fields will only be listed if HasField(field) would
|
// fields, but including extension known to the parser (i.e. compiled in).
|
||||||
// return true and repeated fields will only be listed if FieldSize(field)
|
// Singular fields will only be listed if HasField(field) would return true
|
||||||
// would return non-zero. Fields (both normal fields and extension fields)
|
// and repeated fields will only be listed if FieldSize(field) would return
|
||||||
// will be listed ordered by field number.
|
// non-zero. Fields (both normal fields and extension fields) will be listed
|
||||||
|
// ordered by field number.
|
||||||
|
// Use Reflection::GetUnknownFields() or message.unknown_fields() to also get
|
||||||
|
// access to fields/extensions unknown to the parser.
|
||||||
virtual void ListFields(
|
virtual void ListFields(
|
||||||
const Message& message,
|
const Message& message,
|
||||||
std::vector<const FieldDescriptor*>* output) const = 0;
|
std::vector<const FieldDescriptor*>* output) const = 0;
|
||||||
@@ -519,7 +538,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// will only be present when the new unknown-enum-value semantics are enabled
|
// will only be present when the new unknown-enum-value semantics are enabled
|
||||||
// for a message.)
|
// for a message.)
|
||||||
virtual int GetEnumValue(
|
virtual int GetEnumValue(
|
||||||
const Message& message, const FieldDescriptor* field) const;
|
const Message& message, const FieldDescriptor* field) const = 0;
|
||||||
|
|
||||||
// See MutableMessage() for the meaning of the "factory" parameter.
|
// See MutableMessage() for the meaning of the "factory" parameter.
|
||||||
virtual const Message& GetMessage(const Message& message,
|
virtual const Message& GetMessage(const Message& message,
|
||||||
@@ -575,7 +594,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// messages with new unknown-enum-value semantics.
|
// messages with new unknown-enum-value semantics.
|
||||||
virtual void SetEnumValue(Message* message,
|
virtual void SetEnumValue(Message* message,
|
||||||
const FieldDescriptor* field,
|
const FieldDescriptor* field,
|
||||||
int value) const;
|
int value) const = 0;
|
||||||
|
|
||||||
// Get a mutable pointer to a field with a message type. If a MessageFactory
|
// Get a mutable pointer to a field with a message type. If a MessageFactory
|
||||||
// is provided, it will be used to construct instances of the sub-message;
|
// is provided, it will be used to construct instances of the sub-message;
|
||||||
@@ -646,7 +665,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// for a message.)
|
// for a message.)
|
||||||
virtual int GetRepeatedEnumValue(
|
virtual int GetRepeatedEnumValue(
|
||||||
const Message& message,
|
const Message& message,
|
||||||
const FieldDescriptor* field, int index) const;
|
const FieldDescriptor* field, int index) const = 0;
|
||||||
virtual const Message& GetRepeatedMessage(
|
virtual const Message& GetRepeatedMessage(
|
||||||
const Message& message,
|
const Message& message,
|
||||||
const FieldDescriptor* field, int index) const = 0;
|
const FieldDescriptor* field, int index) const = 0;
|
||||||
@@ -693,7 +712,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// messages with new unknown-enum-value semantics.
|
// messages with new unknown-enum-value semantics.
|
||||||
virtual void SetRepeatedEnumValue(Message* message,
|
virtual void SetRepeatedEnumValue(Message* message,
|
||||||
const FieldDescriptor* field, int index,
|
const FieldDescriptor* field, int index,
|
||||||
int value) const;
|
int value) const = 0;
|
||||||
// Get a mutable pointer to an element of a repeated field with a message
|
// Get a mutable pointer to an element of a repeated field with a message
|
||||||
// type.
|
// type.
|
||||||
virtual Message* MutableRepeatedMessage(
|
virtual Message* MutableRepeatedMessage(
|
||||||
@@ -729,7 +748,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// messages with new unknown-enum-value semantics.
|
// messages with new unknown-enum-value semantics.
|
||||||
virtual void AddEnumValue(Message* message,
|
virtual void AddEnumValue(Message* message,
|
||||||
const FieldDescriptor* field,
|
const FieldDescriptor* field,
|
||||||
int value) const;
|
int value) const = 0;
|
||||||
// See MutableMessage() for comments on the "factory" parameter.
|
// See MutableMessage() for comments on the "factory" parameter.
|
||||||
virtual Message* AddMessage(Message* message,
|
virtual Message* AddMessage(Message* message,
|
||||||
const FieldDescriptor* field,
|
const FieldDescriptor* field,
|
||||||
@@ -739,9 +758,9 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// specifyed by 'field' passing ownership to the message.
|
// specifyed by 'field' passing ownership to the message.
|
||||||
// TODO(tmarek): Make virtual after all subclasses have been
|
// TODO(tmarek): Make virtual after all subclasses have been
|
||||||
// updated.
|
// updated.
|
||||||
virtual void AddAllocatedMessage(Message* /* message */,
|
virtual void AddAllocatedMessage(Message* message,
|
||||||
const FieldDescriptor* /*field */,
|
const FieldDescriptor* field,
|
||||||
Message* /* new_entry */) const {}
|
Message* new_entry) const;
|
||||||
|
|
||||||
|
|
||||||
// Get a RepeatedFieldRef object that can be used to read the underlying
|
// Get a RepeatedFieldRef object that can be used to read the underlying
|
||||||
@@ -848,34 +867,31 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// downgrade to a compatible value or use the UnknownFieldSet if not. For
|
// downgrade to a compatible value or use the UnknownFieldSet if not. For
|
||||||
// example:
|
// example:
|
||||||
//
|
//
|
||||||
// int new_value = GetValueFromApplicationLogic();
|
// int new_value = GetValueFromApplicationLogic();
|
||||||
// if (reflection->SupportsUnknownEnumValues()) {
|
// if (reflection->SupportsUnknownEnumValues()) {
|
||||||
// reflection->SetEnumValue(message, field, new_value);
|
// reflection->SetEnumValue(message, field, new_value);
|
||||||
// } else {
|
// } else {
|
||||||
// if (field_descriptor->enum_type()->
|
// if (field_descriptor->enum_type()->
|
||||||
// FindValueByNumver(new_value) != NULL) {
|
// FindValueByNumber(new_value) != NULL) {
|
||||||
// reflection->SetEnumValue(message, field, new_value);
|
// reflection->SetEnumValue(message, field, new_value);
|
||||||
// } else if (emit_unknown_enum_values) {
|
// } else if (emit_unknown_enum_values) {
|
||||||
// reflection->MutableUnknownFields(message)->AddVarint(
|
// reflection->MutableUnknownFields(message)->AddVarint(
|
||||||
// field->number(),
|
// field->number(), new_value);
|
||||||
// new_value);
|
|
||||||
// } else {
|
// } else {
|
||||||
// // convert value to a compatible/default value.
|
// // convert value to a compatible/default value.
|
||||||
// new_value = CompatibleDowngrade(new_value);
|
// new_value = CompatibleDowngrade(new_value);
|
||||||
// reflection->SetEnumValue(message, field, new_value);
|
// reflection->SetEnumValue(message, field, new_value);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
virtual bool SupportsUnknownEnumValues() const { return false; }
|
virtual bool SupportsUnknownEnumValues() const { return false; }
|
||||||
|
|
||||||
// Returns the MessageFactory associated with this message. This can be
|
// Returns the MessageFactory associated with this message. This can be
|
||||||
// useful for determining if a message is a generated message or not, for
|
// useful for determining if a message is a generated message or not, for
|
||||||
// example:
|
// example:
|
||||||
//
|
// if (message->GetReflection()->GetMessageFactory() ==
|
||||||
// if (message->GetReflection()->GetMessageFactory() ==
|
// google::protobuf::MessageFactory::generated_factory()) {
|
||||||
// google::protobuf::MessageFactory::generated_factory()) {
|
// // This is a generated message.
|
||||||
// // This is a generated message.
|
// }
|
||||||
// }
|
|
||||||
//
|
|
||||||
// It can also be used to create more messages of this type, though
|
// It can also be used to create more messages of this type, though
|
||||||
// Message::New() is an easier way to accomplish this.
|
// Message::New() is an easier way to accomplish this.
|
||||||
virtual MessageFactory* GetMessageFactory() const;
|
virtual MessageFactory* GetMessageFactory() const;
|
||||||
@@ -910,7 +926,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
|
|
||||||
// Returns a raw pointer to the repeated field
|
// Returns a raw pointer to the repeated field
|
||||||
//
|
//
|
||||||
// "cpp_type" and "message_type" are decuded from the type parameter T passed
|
// "cpp_type" and "message_type" are deduced from the type parameter T passed
|
||||||
// to Get(Mutable)RepeatedFieldRef. If T is a generated message type,
|
// to Get(Mutable)RepeatedFieldRef. If T is a generated message type,
|
||||||
// "message_type" should be set to its descriptor. Otherwise "message_type"
|
// "message_type" should be set to its descriptor. Otherwise "message_type"
|
||||||
// should be set to NULL. Implementations of this method should check whether
|
// should be set to NULL. Implementations of this method should check whether
|
||||||
@@ -933,6 +949,10 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
template<typename T, typename Enable>
|
template<typename T, typename Enable>
|
||||||
friend class MutableRepeatedFieldRef;
|
friend class MutableRepeatedFieldRef;
|
||||||
friend class ::google::protobuf::python::MapReflectionFriend;
|
friend class ::google::protobuf::python::MapReflectionFriend;
|
||||||
|
friend class internal::MapFieldReflectionTest;
|
||||||
|
friend class internal::MapKeySorter;
|
||||||
|
friend class internal::WireFormat;
|
||||||
|
friend class internal::ReflectionOps;
|
||||||
|
|
||||||
// Special version for specialized implementations of string. We can't call
|
// Special version for specialized implementations of string. We can't call
|
||||||
// MutableRawRepeatedField directly here because we don't have access to
|
// MutableRawRepeatedField directly here because we don't have access to
|
||||||
@@ -947,7 +967,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
// TODO(jieluo) - make the map APIs pure virtual after updating
|
// TODO(jieluo) - make the map APIs pure virtual after updating
|
||||||
// all the subclasses.
|
// all the subclasses.
|
||||||
// Returns true if key is in map. Returns false if key is not in map field.
|
// Returns true if key is in map. Returns false if key is not in map field.
|
||||||
virtual bool ContainsMapKey(const Message& /* message*/,
|
virtual bool ContainsMapKey(const Message& /* message */,
|
||||||
const FieldDescriptor* /* field */,
|
const FieldDescriptor* /* field */,
|
||||||
const MapKey& /* key */) const {
|
const MapKey& /* key */) const {
|
||||||
return false;
|
return false;
|
||||||
@@ -965,7 +985,7 @@ class LIBPROTOBUF_EXPORT Reflection {
|
|||||||
|
|
||||||
// Delete and returns true if key is in the map field. Returns false
|
// Delete and returns true if key is in the map field. Returns false
|
||||||
// otherwise.
|
// otherwise.
|
||||||
virtual bool DeleteMapValue(Message* /* mesage */,
|
virtual bool DeleteMapValue(Message* /* message */,
|
||||||
const FieldDescriptor* /* field */,
|
const FieldDescriptor* /* field */,
|
||||||
const MapKey& /* key */) const {
|
const MapKey& /* key */) const {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+55
-22
@@ -33,6 +33,8 @@
|
|||||||
// Based on original Protocol Buffers design by
|
// Based on original Protocol Buffers design by
|
||||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/message_lite.h>
|
#include <google/protobuf/message_lite.h>
|
||||||
@@ -101,15 +103,15 @@ string InitializationErrorMessage(const char* action,
|
|||||||
// call MergePartialFromCodedStream(). However, when parsing very small
|
// call MergePartialFromCodedStream(). However, when parsing very small
|
||||||
// messages, every function call introduces significant overhead. To avoid
|
// messages, every function call introduces significant overhead. To avoid
|
||||||
// this without reproducing code, we use these forced-inline helpers.
|
// this without reproducing code, we use these forced-inline helpers.
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineMergeFromCodedStream(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineMergeFromCodedStream(
|
||||||
io::CodedInputStream* input, MessageLite* message);
|
io::CodedInputStream* input, MessageLite* message);
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromCodedStream(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromCodedStream(
|
||||||
io::CodedInputStream* input, MessageLite* message);
|
io::CodedInputStream* input, MessageLite* message);
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromCodedStream(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromCodedStream(
|
||||||
io::CodedInputStream* input, MessageLite* message);
|
io::CodedInputStream* input, MessageLite* message);
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromArray(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromArray(
|
||||||
const void* data, int size, MessageLite* message);
|
const void* data, int size, MessageLite* message);
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromArray(
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromArray(
|
||||||
const void* data, int size, MessageLite* message);
|
const void* data, int size, MessageLite* message);
|
||||||
|
|
||||||
inline bool InlineMergeFromCodedStream(io::CodedInputStream* input,
|
inline bool InlineMergeFromCodedStream(io::CodedInputStream* input,
|
||||||
@@ -220,16 +222,9 @@ bool MessageLite::ParsePartialFromArray(const void* data, int size) {
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
uint8* MessageLite::InternalSerializeWithCachedSizesToArray(
|
uint8* MessageLite::SerializeWithCachedSizesToArray(uint8* target) const {
|
||||||
bool deterministic, uint8* target) const {
|
return InternalSerializeWithCachedSizesToArray(
|
||||||
// We only optimize this when using optimize_for = SPEED. In other cases
|
io::CodedOutputStream::IsDefaultSerializationDeterministic(), target);
|
||||||
// we just use the CodedOutputStream path.
|
|
||||||
int size = GetCachedSize();
|
|
||||||
io::ArrayOutputStream out(target, size);
|
|
||||||
io::CodedOutputStream coded_out(&out);
|
|
||||||
SerializeWithCachedSizes(&coded_out);
|
|
||||||
GOOGLE_CHECK(!coded_out.HadError());
|
|
||||||
return target + size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
|
bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
|
||||||
@@ -237,21 +232,18 @@ bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
|
|||||||
return SerializePartialToCodedStream(output);
|
return SerializePartialToCodedStream(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MessageLite::ByteSizeLong() const {
|
|
||||||
return internal::FromIntSize(ByteSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MessageLite::SerializePartialToCodedStream(
|
bool MessageLite::SerializePartialToCodedStream(
|
||||||
io::CodedOutputStream* output) const {
|
io::CodedOutputStream* output) const {
|
||||||
const size_t size = ByteSizeLong(); // Force size to be cached.
|
const size_t size = ByteSizeLong(); // Force size to be cached.
|
||||||
if (size > INT_MAX) {
|
if (size > INT_MAX) {
|
||||||
GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB.";
|
GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size);
|
uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size);
|
||||||
if (buffer != NULL) {
|
if (buffer != NULL) {
|
||||||
uint8* end = SerializeWithCachedSizesToArray(buffer);
|
uint8* end = InternalSerializeWithCachedSizesToArray(
|
||||||
|
output->IsSerializationDeterministic(), buffer);
|
||||||
if (end - buffer != size) {
|
if (end - buffer != size) {
|
||||||
ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this);
|
ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this);
|
||||||
}
|
}
|
||||||
@@ -294,7 +286,7 @@ bool MessageLite::AppendPartialToString(string* output) const {
|
|||||||
size_t old_size = output->size();
|
size_t old_size = output->size();
|
||||||
size_t byte_size = ByteSizeLong();
|
size_t byte_size = ByteSizeLong();
|
||||||
if (byte_size > INT_MAX) {
|
if (byte_size > INT_MAX) {
|
||||||
GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB.";
|
GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << byte_size;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,6 +344,39 @@ string MessageLite::SerializePartialAsString() const {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLite::SerializeWithCachedSizes(
|
||||||
|
io::CodedOutputStream* output) const {
|
||||||
|
GOOGLE_DCHECK(InternalGetTable());
|
||||||
|
internal::TableSerialize(
|
||||||
|
*this,
|
||||||
|
static_cast<const internal::SerializationTable*>(InternalGetTable()),
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The table driven code optimizes the case that the CodedOutputStream buffer
|
||||||
|
// is large enough to serialize into it directly.
|
||||||
|
// If the proto is optimized for speed, this method will be overridden by
|
||||||
|
// generated code for maximum speed. If the proto is optimized for size or
|
||||||
|
// is lite, then we need to specialize this to avoid infinite recursion.
|
||||||
|
uint8* MessageLite::InternalSerializeWithCachedSizesToArray(
|
||||||
|
bool deterministic, uint8* target) const {
|
||||||
|
const internal::SerializationTable* table =
|
||||||
|
static_cast<const internal::SerializationTable*>(InternalGetTable());
|
||||||
|
if (table == NULL) {
|
||||||
|
// We only optimize this when using optimize_for = SPEED. In other cases
|
||||||
|
// we just use the CodedOutputStream path.
|
||||||
|
int size = GetCachedSize();
|
||||||
|
io::ArrayOutputStream out(target, size);
|
||||||
|
io::CodedOutputStream coded_out(&out);
|
||||||
|
coded_out.SetSerializationDeterministic(deterministic);
|
||||||
|
SerializeWithCachedSizes(&coded_out);
|
||||||
|
GOOGLE_CHECK(!coded_out.HadError());
|
||||||
|
return target + size;
|
||||||
|
} else {
|
||||||
|
return internal::TableSerializeToArray(*this, table, deterministic, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template<>
|
template<>
|
||||||
MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
|
MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
|
||||||
@@ -368,6 +393,14 @@ void GenericTypeHandler<string>::Merge(const string& from,
|
|||||||
string* to) {
|
string* to) {
|
||||||
*to = from;
|
*to = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool proto3_preserve_unknown_ = true;
|
||||||
|
|
||||||
|
void SetProto3PreserveUnknownsDefault(bool preserve) {
|
||||||
|
proto3_preserve_unknown_ = preserve;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|||||||
+164
-49
@@ -39,22 +39,115 @@
|
|||||||
#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
||||||
#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/stubs/logging.h>
|
||||||
|
#include <google/protobuf/stubs/once.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
class Arena;
|
class Arena;
|
||||||
namespace io {
|
namespace io {
|
||||||
class CodedInputStream;
|
class CodedInputStream;
|
||||||
class CodedOutputStream;
|
class CodedOutputStream;
|
||||||
class ZeroCopyInputStream;
|
class ZeroCopyInputStream;
|
||||||
class ZeroCopyOutputStream;
|
class ZeroCopyOutputStream;
|
||||||
}
|
}
|
||||||
namespace internal {
|
namespace internal {
|
||||||
class WireFormatLite;
|
|
||||||
|
class WireFormatLite;
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
|
// We compute sizes as size_t but cache them as int. This function converts a
|
||||||
|
// computed size to a cached size. Since we don't proceed with serialization
|
||||||
|
// if the total size was > INT_MAX, it is not important what this function
|
||||||
|
// returns for inputs > INT_MAX. However this case should not error or
|
||||||
|
// GOOGLE_CHECK-fail, because the full size_t resolution is still returned from
|
||||||
|
// ByteSizeLong() and checked against INT_MAX; we can catch the overflow
|
||||||
|
// there.
|
||||||
|
inline int ToCachedSize(size_t size) { return static_cast<int>(size); }
|
||||||
|
|
||||||
|
// We mainly calculate sizes in terms of size_t, but some functions that
|
||||||
|
// compute sizes return "int". These int sizes are expected to always be
|
||||||
|
// positive. This function is more efficient than casting an int to size_t
|
||||||
|
// directly on 64-bit platforms because it avoids making the compiler emit a
|
||||||
|
// sign extending instruction, which we don't want and don't want to pay for.
|
||||||
|
inline size_t FromIntSize(int size) {
|
||||||
|
// Convert to unsigned before widening so sign extension is not necessary.
|
||||||
|
return static_cast<unsigned int>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For cases where a legacy function returns an integer size. We GOOGLE_DCHECK()
|
||||||
|
// that the conversion will fit within an integer; if this is false then we
|
||||||
|
// are losing information.
|
||||||
|
inline int ToIntSize(size_t size) {
|
||||||
|
GOOGLE_DCHECK_LE(size, static_cast<size_t>(INT_MAX));
|
||||||
|
return static_cast<int>(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This type wraps a variable whose constructor and destructor are explicitly
|
||||||
|
// called. It is particularly useful for a global variable, without its
|
||||||
|
// constructor and destructor run on start and end of the program lifetime.
|
||||||
|
// This circumvents the initial construction order fiasco, while keeping
|
||||||
|
// the address of the empty string a compile time constant.
|
||||||
|
//
|
||||||
|
// Pay special attention to the initialization state of the object.
|
||||||
|
// 1. The object is "uninitialized" to begin with.
|
||||||
|
// 2. Call DefaultConstruct() only if the object is uninitialized.
|
||||||
|
// After the call, the object becomes "initialized".
|
||||||
|
// 3. Call get() and get_mutable() only if the object is initialized.
|
||||||
|
// 4. Call Destruct() only if the object is initialized.
|
||||||
|
// After the call, the object becomes uninitialized.
|
||||||
|
template <typename T>
|
||||||
|
class ExplicitlyConstructed {
|
||||||
|
public:
|
||||||
|
void DefaultConstruct() {
|
||||||
|
new (&union_) T();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Destruct() {
|
||||||
|
get_mutable()->~T();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
constexpr
|
||||||
|
#endif
|
||||||
|
const T&
|
||||||
|
get() const {
|
||||||
|
return reinterpret_cast<const T&>(union_);
|
||||||
|
}
|
||||||
|
T* get_mutable() { return reinterpret_cast<T*>(&union_); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Prefer c++14 aligned_storage, but for compatibility this will do.
|
||||||
|
union AlignedUnion {
|
||||||
|
char space[sizeof(T)];
|
||||||
|
int64 align_to_int64;
|
||||||
|
void* align_to_ptr;
|
||||||
|
} union_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default empty string object. Don't use this directly. Instead, call
|
||||||
|
// GetEmptyString() to get the reference.
|
||||||
|
extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
|
||||||
|
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
|
||||||
|
LIBPROTOBUF_EXPORT void InitEmptyString();
|
||||||
|
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {
|
||||||
|
return fixed_address_empty_string.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
|
||||||
|
::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
|
||||||
|
return GetEmptyStringAlreadyInited();
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str);
|
||||||
|
#endif // SWIG
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
// Interface to light weight protocol messages.
|
// Interface to light weight protocol messages.
|
||||||
//
|
//
|
||||||
// This interface is implemented by all protocol message objects. Non-lite
|
// This interface is implemented by all protocol message objects. Non-lite
|
||||||
@@ -99,18 +192,19 @@ class LIBPROTOBUF_EXPORT MessageLite {
|
|||||||
// Get the arena, if any, associated with this message. Virtual method
|
// Get the arena, if any, associated with this message. Virtual method
|
||||||
// required for generic operations but most arena-related operations should
|
// required for generic operations but most arena-related operations should
|
||||||
// use the GetArenaNoVirtual() generated-code method. Default implementation
|
// use the GetArenaNoVirtual() generated-code method. Default implementation
|
||||||
// to reduce code size by avoiding the need for per-type implementations when
|
// to reduce code size by avoiding the need for per-type implementations
|
||||||
// types do not implement arena support.
|
// when types do not implement arena support.
|
||||||
virtual ::google::protobuf::Arena* GetArena() const { return NULL; }
|
virtual ::google::protobuf::Arena* GetArena() const { return NULL; }
|
||||||
|
|
||||||
// Get a pointer that may be equal to this message's arena, or may not be. If
|
// Get a pointer that may be equal to this message's arena, or may not be.
|
||||||
// the value returned by this method is equal to some arena pointer, then this
|
// If the value returned by this method is equal to some arena pointer, then
|
||||||
// message is on that arena; however, if this message is on some arena, this
|
// this message is on that arena; however, if this message is on some arena,
|
||||||
// method may or may not return that arena's pointer. As a tradeoff, this
|
// this method may or may not return that arena's pointer. As a tradeoff,
|
||||||
// method may be more efficient than GetArena(). The intent is to allow
|
// this method may be more efficient than GetArena(). The intent is to allow
|
||||||
// underlying representations that use e.g. tagged pointers to sometimes store
|
// underlying representations that use e.g. tagged pointers to sometimes
|
||||||
// the arena pointer directly, and sometimes in a more indirect way, and allow
|
// store the arena pointer directly, and sometimes in a more indirect way,
|
||||||
// a fastpath comparison against the arena pointer when it's easy to obtain.
|
// and allow a fastpath comparison against the arena pointer when it's easy
|
||||||
|
// to obtain.
|
||||||
virtual void* GetMaybeArenaPointer() const { return GetArena(); }
|
virtual void* GetMaybeArenaPointer() const { return GetArena(); }
|
||||||
|
|
||||||
// Clear all fields of the message and set them to their default values.
|
// Clear all fields of the message and set them to their default values.
|
||||||
@@ -128,19 +222,20 @@ class LIBPROTOBUF_EXPORT MessageLite {
|
|||||||
// for full messages. See message.h.
|
// for full messages. See message.h.
|
||||||
virtual string InitializationErrorString() const;
|
virtual string InitializationErrorString() const;
|
||||||
|
|
||||||
// If |other| is the exact same class as this, calls MergeFrom(). Otherwise,
|
// If |other| is the exact same class as this, calls MergeFrom(). Otherwise,
|
||||||
// results are undefined (probably crash).
|
// results are undefined (probably crash).
|
||||||
virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0;
|
virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0;
|
||||||
|
|
||||||
// Parsing ---------------------------------------------------------
|
// Parsing ---------------------------------------------------------
|
||||||
// Methods for parsing in protocol buffer format. Most of these are
|
// Methods for parsing in protocol buffer format. Most of these are
|
||||||
// just simple wrappers around MergeFromCodedStream(). Clear() will be called
|
// just simple wrappers around MergeFromCodedStream(). Clear() will be
|
||||||
// before merging the input.
|
// called before merging the input.
|
||||||
|
|
||||||
// Fill the message with a protocol buffer parsed from the given input stream.
|
// Fill the message with a protocol buffer parsed from the given input
|
||||||
// Returns false on a read error or if the input is in the wrong format. A
|
// stream. Returns false on a read error or if the input is in the wrong
|
||||||
// successful return does not indicate the entire input is consumed, ensure
|
// format. A successful return does not indicate the entire input is
|
||||||
// you call ConsumedEntireMessage() to check that if applicable.
|
// consumed, ensure you call ConsumedEntireMessage() to check that if
|
||||||
|
// applicable.
|
||||||
bool ParseFromCodedStream(io::CodedInputStream* input);
|
bool ParseFromCodedStream(io::CodedInputStream* input);
|
||||||
// Like ParseFromCodedStream(), but accepts messages that are missing
|
// Like ParseFromCodedStream(), but accepts messages that are missing
|
||||||
// required fields.
|
// required fields.
|
||||||
@@ -239,26 +334,36 @@ class LIBPROTOBUF_EXPORT MessageLite {
|
|||||||
bool AppendPartialToString(string* output) const;
|
bool AppendPartialToString(string* output) const;
|
||||||
|
|
||||||
// Computes the serialized size of the message. This recursively calls
|
// Computes the serialized size of the message. This recursively calls
|
||||||
// ByteSize() on all embedded messages. Subclasses MUST override either
|
// ByteSizeLong() on all embedded messages.
|
||||||
// ByteSize() or ByteSizeLong() (overriding both is fine).
|
|
||||||
//
|
//
|
||||||
// ByteSize() is generally linear in the number of fields defined for the
|
// ByteSizeLong() is generally linear in the number of fields defined for the
|
||||||
// proto.
|
// proto.
|
||||||
virtual int ByteSize() const { return ByteSizeLong(); }
|
virtual size_t ByteSizeLong() const = 0;
|
||||||
virtual size_t ByteSizeLong() const;
|
|
||||||
|
|
||||||
// Serializes the message without recomputing the size. The message must
|
// Legacy ByteSize() API.
|
||||||
// not have changed since the last call to ByteSize(); if it has, the results
|
PROTOBUF_RUNTIME_DEPRECATED("Please use ByteSizeLong() instead")
|
||||||
// are undefined.
|
int ByteSize() const {
|
||||||
virtual void SerializeWithCachedSizes(
|
return internal::ToIntSize(ByteSizeLong());
|
||||||
io::CodedOutputStream* output) const = 0;
|
|
||||||
|
|
||||||
// A version of SerializeWithCachedSizesToArray, below, that does
|
|
||||||
// not guarantee deterministic serialization.
|
|
||||||
virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const {
|
|
||||||
return InternalSerializeWithCachedSizesToArray(false, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serializes the message without recomputing the size. The message must not
|
||||||
|
// have changed since the last call to ByteSize(), and the value returned by
|
||||||
|
// ByteSize must be non-negative. Otherwise the results are undefined.
|
||||||
|
virtual void SerializeWithCachedSizes(
|
||||||
|
io::CodedOutputStream* output) const;
|
||||||
|
|
||||||
|
// Functions below here are not part of the public interface. It isn't
|
||||||
|
// enforced, but they should be treated as private, and will be private
|
||||||
|
// at some future time. Unfortunately the implementation of the "friend"
|
||||||
|
// keyword in GCC is broken at the moment, but we expect it will be fixed.
|
||||||
|
|
||||||
|
// Like SerializeWithCachedSizes, but writes directly to *target, returning
|
||||||
|
// a pointer to the byte immediately after the last byte written. "target"
|
||||||
|
// must point at a byte array of at least ByteSize() bytes. Whether to use
|
||||||
|
// deterministic serialization, e.g., maps in sorted order, is determined by
|
||||||
|
// CodedOutputStream::IsDefaultSerializationDeterministic().
|
||||||
|
virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const;
|
||||||
|
|
||||||
// Returns the result of the last call to ByteSize(). An embedded message's
|
// Returns the result of the last call to ByteSize(). An embedded message's
|
||||||
// size is needed both to serialize it (because embedded messages are
|
// size is needed both to serialize it (because embedded messages are
|
||||||
// length-delimited) and to compute the outer message's size. Caching
|
// length-delimited) and to compute the outer message's size. Caching
|
||||||
@@ -272,25 +377,35 @@ class LIBPROTOBUF_EXPORT MessageLite {
|
|||||||
// method.)
|
// method.)
|
||||||
virtual int GetCachedSize() const = 0;
|
virtual int GetCachedSize() const = 0;
|
||||||
|
|
||||||
// Functions below here are not part of the public interface. It isn't
|
|
||||||
// enforced, but they should be treated as private, and will be private
|
|
||||||
// at some future time. Unfortunately the implementation of the "friend"
|
|
||||||
// keyword in GCC is broken at the moment, but we expect it will be fixed.
|
|
||||||
|
|
||||||
// Like SerializeWithCachedSizes, but writes directly to *target, returning
|
|
||||||
// a pointer to the byte immediately after the last byte written. "target"
|
|
||||||
// must point at a byte array of at least ByteSize() bytes. If deterministic
|
|
||||||
// is true then we use deterministic serialization, e.g., map keys are sorted.
|
|
||||||
// FOR INTERNAL USE ONLY!
|
|
||||||
virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
|
virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
|
||||||
uint8* target) const;
|
uint8* target) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// TODO(gerbens) make this a pure abstract function
|
||||||
|
virtual const void* InternalGetTable() const { return NULL; }
|
||||||
|
|
||||||
friend class internal::WireFormatLite;
|
friend class internal::WireFormatLite;
|
||||||
|
friend class Message;
|
||||||
|
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
extern bool LIBPROTOBUF_EXPORT proto3_preserve_unknown_;
|
||||||
|
|
||||||
|
// DO NOT USE: For migration only. Will be removed when Proto3 defaults to
|
||||||
|
// preserve unknowns.
|
||||||
|
inline bool GetProto3PreserveUnknownsDefault() {
|
||||||
|
return proto3_preserve_unknown_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DO NOT USE: For migration only. Will be removed when Proto3 defaults to
|
||||||
|
// preserve unknowns.
|
||||||
|
void LIBPROTOBUF_EXPORT SetProto3PreserveUnknownsDefault(bool preserve);
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
|
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|||||||
+15
-96
@@ -38,117 +38,36 @@
|
|||||||
#ifndef GOOGLE_PROTOBUF_METADATA_H__
|
#ifndef GOOGLE_PROTOBUF_METADATA_H__
|
||||||
#define GOOGLE_PROTOBUF_METADATA_H__
|
#define GOOGLE_PROTOBUF_METADATA_H__
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/metadata_lite.h>
|
||||||
#include <google/protobuf/arena.h>
|
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// This is the representation for messages that support arena allocation. It
|
class InternalMetadataWithArena
|
||||||
// uses a tagged pointer to either store the Arena pointer, if there are no
|
: public InternalMetadataWithArenaBase<UnknownFieldSet,
|
||||||
// unknown fields, or a pointer to a block of memory with both the Arena pointer
|
InternalMetadataWithArena> {
|
||||||
// and the UnknownFieldSet, if there are unknown fields. This optimization
|
|
||||||
// allows for "zero-overhead" storage of the Arena pointer, relative to the
|
|
||||||
// above baseline implementation.
|
|
||||||
//
|
|
||||||
// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
|
|
||||||
// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container
|
|
||||||
// pointer.
|
|
||||||
class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
|
|
||||||
public:
|
public:
|
||||||
InternalMetadataWithArena() : ptr_(NULL) {}
|
InternalMetadataWithArena() {}
|
||||||
explicit InternalMetadataWithArena(Arena* arena)
|
explicit InternalMetadataWithArena(Arena* arena)
|
||||||
: ptr_ (arena) {}
|
: InternalMetadataWithArenaBase<UnknownFieldSet,
|
||||||
|
InternalMetadataWithArena>(arena) {}
|
||||||
|
|
||||||
~InternalMetadataWithArena() {
|
void DoSwap(UnknownFieldSet* other) {
|
||||||
if (have_unknown_fields() && arena() == NULL) {
|
mutable_unknown_fields()->Swap(other);
|
||||||
delete PtrValue<Container>();
|
|
||||||
}
|
|
||||||
ptr_ = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const {
|
void DoMergeFrom(const UnknownFieldSet& other) {
|
||||||
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
mutable_unknown_fields()->MergeFrom(other);
|
||||||
return PtrValue<Container>()->unknown_fields_;
|
|
||||||
} else {
|
|
||||||
return *UnknownFieldSet::default_instance();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() {
|
void DoClear() {
|
||||||
if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {
|
mutable_unknown_fields()->Clear();
|
||||||
return &PtrValue<Container>()->unknown_fields_;
|
|
||||||
} else {
|
|
||||||
return mutable_unknown_fields_slow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {
|
static const UnknownFieldSet& default_instance() {
|
||||||
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
return *UnknownFieldSet::default_instance();
|
||||||
return PtrValue<Container>()->arena_;
|
|
||||||
} else {
|
|
||||||
return PtrValue<Arena>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const {
|
|
||||||
return PtrTag() == kTagContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) {
|
|
||||||
// Semantics here are that we swap only the unknown fields, not the arena
|
|
||||||
// pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
|
|
||||||
// maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
|
|
||||||
// different states (direct arena pointer vs. container with UFS) so we
|
|
||||||
// cannot simply swap ptr_ and then restore the arena pointers. We reuse
|
|
||||||
// UFS's swap implementation instead.
|
|
||||||
if (have_unknown_fields() || other->have_unknown_fields()) {
|
|
||||||
mutable_unknown_fields()->Swap(other->mutable_unknown_fields());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const {
|
|
||||||
return ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void* ptr_;
|
|
||||||
|
|
||||||
// Tagged pointer implementation.
|
|
||||||
enum {
|
|
||||||
// ptr_ is an Arena*.
|
|
||||||
kTagArena = 0,
|
|
||||||
// ptr_ is a Container*.
|
|
||||||
kTagContainer = 1,
|
|
||||||
};
|
|
||||||
static const intptr_t kPtrTagMask = 1;
|
|
||||||
static const intptr_t kPtrValueMask = ~kPtrTagMask;
|
|
||||||
|
|
||||||
// Accessors for pointer tag and pointer value.
|
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const {
|
|
||||||
return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> T* PtrValue() const {
|
|
||||||
return reinterpret_cast<T*>(
|
|
||||||
reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If ptr_'s tag is kTagContainer, it points to an instance of this struct.
|
|
||||||
struct Container {
|
|
||||||
UnknownFieldSet unknown_fields_;
|
|
||||||
Arena* arena_;
|
|
||||||
};
|
|
||||||
|
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() {
|
|
||||||
Arena* my_arena = arena();
|
|
||||||
Container* container = Arena::Create<Container>(my_arena);
|
|
||||||
ptr_ = reinterpret_cast<void*>(
|
|
||||||
reinterpret_cast<intptr_t>(container) | kTagContainer);
|
|
||||||
container->arena_ = my_arena;
|
|
||||||
return &(container->unknown_fields_);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PROTOBUF_METADATA_LITE_H__
|
||||||
|
#define GOOGLE_PROTOBUF_METADATA_LITE_H__
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
#include <google/protobuf/arena.h>
|
||||||
|
#include <google/protobuf/message_lite.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
// This is the representation for messages that support arena allocation. It
|
||||||
|
// uses a tagged pointer to either store the Arena pointer, if there are no
|
||||||
|
// unknown fields, or a pointer to a block of memory with both the Arena pointer
|
||||||
|
// and the UnknownFieldSet, if there are unknown fields. This optimization
|
||||||
|
// allows for "zero-overhead" storage of the Arena pointer, relative to the
|
||||||
|
// above baseline implementation.
|
||||||
|
//
|
||||||
|
// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
|
||||||
|
// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container
|
||||||
|
// pointer.
|
||||||
|
template <class T, class Derived>
|
||||||
|
class InternalMetadataWithArenaBase {
|
||||||
|
public:
|
||||||
|
InternalMetadataWithArenaBase() : ptr_(NULL) {}
|
||||||
|
explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {}
|
||||||
|
|
||||||
|
~InternalMetadataWithArenaBase() {
|
||||||
|
if (have_unknown_fields() && arena() == NULL) {
|
||||||
|
delete PtrValue<Container>();
|
||||||
|
}
|
||||||
|
ptr_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const {
|
||||||
|
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
||||||
|
return PtrValue<Container>()->unknown_fields;
|
||||||
|
} else {
|
||||||
|
return Derived::default_instance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() {
|
||||||
|
if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {
|
||||||
|
return &PtrValue<Container>()->unknown_fields;
|
||||||
|
} else {
|
||||||
|
return mutable_unknown_fields_slow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {
|
||||||
|
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
||||||
|
return PtrValue<Container>()->arena;
|
||||||
|
} else {
|
||||||
|
return PtrValue<Arena>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const {
|
||||||
|
return PtrTag() == kTagContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) {
|
||||||
|
// Semantics here are that we swap only the unknown fields, not the arena
|
||||||
|
// pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
|
||||||
|
// maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
|
||||||
|
// different states (direct arena pointer vs. container with UFS) so we
|
||||||
|
// cannot simply swap ptr_ and then restore the arena pointers. We reuse
|
||||||
|
// UFS's swap implementation instead.
|
||||||
|
if (have_unknown_fields() || other->have_unknown_fields()) {
|
||||||
|
static_cast<Derived*>(this)->DoSwap(other->mutable_unknown_fields());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) {
|
||||||
|
if (other.have_unknown_fields()) {
|
||||||
|
static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void Clear() {
|
||||||
|
if (have_unknown_fields()) {
|
||||||
|
static_cast<Derived*>(this)->DoClear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const {
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void* ptr_;
|
||||||
|
|
||||||
|
// Tagged pointer implementation.
|
||||||
|
enum {
|
||||||
|
// ptr_ is an Arena*.
|
||||||
|
kTagArena = 0,
|
||||||
|
// ptr_ is a Container*.
|
||||||
|
kTagContainer = 1,
|
||||||
|
};
|
||||||
|
static const intptr_t kPtrTagMask = 1;
|
||||||
|
static const intptr_t kPtrValueMask = ~kPtrTagMask;
|
||||||
|
|
||||||
|
// Accessors for pointer tag and pointer value.
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const {
|
||||||
|
return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U> U* PtrValue() const {
|
||||||
|
return reinterpret_cast<U*>(
|
||||||
|
reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If ptr_'s tag is kTagContainer, it points to an instance of this struct.
|
||||||
|
struct Container {
|
||||||
|
T unknown_fields;
|
||||||
|
Arena* arena;
|
||||||
|
};
|
||||||
|
|
||||||
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() {
|
||||||
|
Arena* my_arena = arena();
|
||||||
|
Container* container = Arena::Create<Container>(my_arena);
|
||||||
|
// Two-step assignment works around a bug in clang's static analyzer:
|
||||||
|
// https://bugs.llvm.org/show_bug.cgi?id=34198.
|
||||||
|
ptr_ = container;
|
||||||
|
ptr_ = reinterpret_cast<void*>(
|
||||||
|
reinterpret_cast<intptr_t>(ptr_) | kTagContainer);
|
||||||
|
container->arena = my_arena;
|
||||||
|
return &(container->unknown_fields);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// We store unknown fields as a string right now, because there is currently no
|
||||||
|
// good interface for reading unknown fields into an ArenaString. We may want
|
||||||
|
// to revisit this to allow unknown fields to be parsed onto the Arena.
|
||||||
|
class InternalMetadataWithArenaLite
|
||||||
|
: public InternalMetadataWithArenaBase<string,
|
||||||
|
InternalMetadataWithArenaLite> {
|
||||||
|
public:
|
||||||
|
InternalMetadataWithArenaLite() {}
|
||||||
|
|
||||||
|
explicit InternalMetadataWithArenaLite(Arena* arena)
|
||||||
|
: InternalMetadataWithArenaBase<string,
|
||||||
|
InternalMetadataWithArenaLite>(arena) {}
|
||||||
|
|
||||||
|
void DoSwap(string* other) {
|
||||||
|
mutable_unknown_fields()->swap(*other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoMergeFrom(const string& other) {
|
||||||
|
mutable_unknown_fields()->append(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoClear() {
|
||||||
|
mutable_unknown_fields()->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const string& default_instance() {
|
||||||
|
return GetEmptyStringAlreadyInited();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// This helper RAII class is needed to efficiently parse unknown fields. We
|
||||||
|
// should only call mutable_unknown_fields if there are actual unknown fields.
|
||||||
|
// The obvious thing to just use a stack string and swap it at the end of the
|
||||||
|
// parse won't work, because the destructor of StringOutputStream needs to be
|
||||||
|
// called before we can modify the string (it check-fails). Using
|
||||||
|
// LiteUnknownFieldSetter setter(&_internal_metadata_);
|
||||||
|
// StringOutputStream stream(setter.buffer());
|
||||||
|
// guarantees that the string is only swapped after stream is destroyed.
|
||||||
|
class LIBPROTOBUF_EXPORT LiteUnknownFieldSetter {
|
||||||
|
public:
|
||||||
|
explicit LiteUnknownFieldSetter(InternalMetadataWithArenaLite* metadata)
|
||||||
|
: metadata_(metadata) {
|
||||||
|
if (metadata->have_unknown_fields()) {
|
||||||
|
buffer_.swap(*metadata->mutable_unknown_fields());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~LiteUnknownFieldSetter() {
|
||||||
|
if (!buffer_.empty()) metadata_->mutable_unknown_fields()->swap(buffer_);
|
||||||
|
}
|
||||||
|
string* buffer() { return &buffer_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
InternalMetadataWithArenaLite* metadata_;
|
||||||
|
string buffer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace protobuf
|
||||||
|
|
||||||
|
} // namespace google
|
||||||
|
#endif // GOOGLE_PROTOBUF_METADATA_LITE_H__
|
||||||
+2
-2
@@ -570,8 +570,8 @@ struct RefTypeTraits<
|
|||||||
typedef RepeatedFieldRefIterator<T> iterator;
|
typedef RepeatedFieldRefIterator<T> iterator;
|
||||||
typedef RepeatedFieldAccessor AccessorType;
|
typedef RepeatedFieldAccessor AccessorType;
|
||||||
typedef string AccessorValueType;
|
typedef string AccessorValueType;
|
||||||
typedef string IteratorValueType;
|
typedef const string IteratorValueType;
|
||||||
typedef string* IteratorPointerType;
|
typedef const string* IteratorPointerType;
|
||||||
static const FieldDescriptor::CppType cpp_type =
|
static const FieldDescriptor::CppType cpp_type =
|
||||||
FieldDescriptor::CPPTYPE_STRING;
|
FieldDescriptor::CPPTYPE_STRING;
|
||||||
static const Descriptor* GetMessageFieldDescriptor() {
|
static const Descriptor* GetMessageFieldDescriptor() {
|
||||||
|
|||||||
+28
-6
@@ -38,6 +38,7 @@
|
|||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/descriptor.h>
|
#include <google/protobuf/descriptor.h>
|
||||||
#include <google/protobuf/descriptor.pb.h>
|
#include <google/protobuf/descriptor.pb.h>
|
||||||
|
#include <google/protobuf/map_field.h>
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
#include <google/protobuf/stubs/strutil.h>
|
#include <google/protobuf/stubs/strutil.h>
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
|
|||||||
const Reflection* from_reflection = from.GetReflection();
|
const Reflection* from_reflection = from.GetReflection();
|
||||||
const Reflection* to_reflection = to->GetReflection();
|
const Reflection* to_reflection = to->GetReflection();
|
||||||
|
|
||||||
vector<const FieldDescriptor*> fields;
|
std::vector<const FieldDescriptor*> fields;
|
||||||
from_reflection->ListFields(from, &fields);
|
from_reflection->ListFields(from, &fields);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
const FieldDescriptor* field = fields[i];
|
const FieldDescriptor* field = fields[i];
|
||||||
@@ -129,7 +130,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
|
|||||||
void ReflectionOps::Clear(Message* message) {
|
void ReflectionOps::Clear(Message* message) {
|
||||||
const Reflection* reflection = message->GetReflection();
|
const Reflection* reflection = message->GetReflection();
|
||||||
|
|
||||||
vector<const FieldDescriptor*> fields;
|
std::vector<const FieldDescriptor*> fields;
|
||||||
reflection->ListFields(*message, &fields);
|
reflection->ListFields(*message, &fields);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
reflection->ClearField(message, fields[i]);
|
reflection->ClearField(message, fields[i]);
|
||||||
@@ -152,12 +153,33 @@ bool ReflectionOps::IsInitialized(const Message& message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that sub-messages are initialized.
|
// Check that sub-messages are initialized.
|
||||||
vector<const FieldDescriptor*> fields;
|
std::vector<const FieldDescriptor*> fields;
|
||||||
reflection->ListFields(message, &fields);
|
reflection->ListFields(message, &fields);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
const FieldDescriptor* field = fields[i];
|
const FieldDescriptor* field = fields[i];
|
||||||
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
|
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
|
||||||
|
|
||||||
|
if (field->is_map()) {
|
||||||
|
const FieldDescriptor* value_field = field->message_type()->field(1);
|
||||||
|
if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
|
||||||
|
MapFieldBase* map_field =
|
||||||
|
reflection->MapData(const_cast<Message*>(&message), field);
|
||||||
|
if (map_field->IsMapValid()) {
|
||||||
|
MapIterator iter(const_cast<Message*>(&message), field);
|
||||||
|
MapIterator end(const_cast<Message*>(&message), field);
|
||||||
|
for (map_field->MapBegin(&iter), map_field->MapEnd(&end);
|
||||||
|
iter != end; ++iter) {
|
||||||
|
if (!iter.GetValueRef().GetMessageValue().IsInitialized()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (field->is_repeated()) {
|
if (field->is_repeated()) {
|
||||||
int size = reflection->FieldSize(message, field);
|
int size = reflection->FieldSize(message, field);
|
||||||
|
|
||||||
@@ -183,7 +205,7 @@ void ReflectionOps::DiscardUnknownFields(Message* message) {
|
|||||||
|
|
||||||
reflection->MutableUnknownFields(message)->Clear();
|
reflection->MutableUnknownFields(message)->Clear();
|
||||||
|
|
||||||
vector<const FieldDescriptor*> fields;
|
std::vector<const FieldDescriptor*> fields;
|
||||||
reflection->ListFields(*message, &fields);
|
reflection->ListFields(*message, &fields);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
const FieldDescriptor* field = fields[i];
|
const FieldDescriptor* field = fields[i];
|
||||||
@@ -224,7 +246,7 @@ static string SubMessagePrefix(const string& prefix,
|
|||||||
void ReflectionOps::FindInitializationErrors(
|
void ReflectionOps::FindInitializationErrors(
|
||||||
const Message& message,
|
const Message& message,
|
||||||
const string& prefix,
|
const string& prefix,
|
||||||
vector<string>* errors) {
|
std::vector<string>* errors) {
|
||||||
const Descriptor* descriptor = message.GetDescriptor();
|
const Descriptor* descriptor = message.GetDescriptor();
|
||||||
const Reflection* reflection = message.GetReflection();
|
const Reflection* reflection = message.GetReflection();
|
||||||
|
|
||||||
@@ -238,7 +260,7 @@ void ReflectionOps::FindInitializationErrors(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check sub-messages.
|
// Check sub-messages.
|
||||||
vector<const FieldDescriptor*> fields;
|
std::vector<const FieldDescriptor*> fields;
|
||||||
reflection->ListFields(message, &fields);
|
reflection->ListFields(message, &fields);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
const FieldDescriptor* field = fields[i];
|
const FieldDescriptor* field = fields[i];
|
||||||
|
|||||||
+283
-130
@@ -51,18 +51,20 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
#include <google/protobuf/stubs/casts.h>
|
#include <google/protobuf/stubs/casts.h>
|
||||||
#include <google/protobuf/stubs/logging.h>
|
#include <google/protobuf/stubs/logging.h>
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
#include <google/protobuf/stubs/type_traits.h>
|
#include <google/protobuf/stubs/type_traits.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
|
||||||
#include <google/protobuf/message_lite.h>
|
#include <google/protobuf/message_lite.h>
|
||||||
|
#include <google/protobuf/stubs/port.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Forward-declare these so that we can make them friends.
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
namespace upb {
|
namespace upb {
|
||||||
namespace google_opensource {
|
namespace google_opensource {
|
||||||
class GMR_Handlers;
|
class GMR_Handlers;
|
||||||
@@ -75,6 +77,8 @@ class Message;
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
class MergePartialFromCodedStreamHelper;
|
||||||
|
|
||||||
static const int kMinRepeatedFieldAllocationSize = 4;
|
static const int kMinRepeatedFieldAllocationSize = 4;
|
||||||
|
|
||||||
// A utility function for logging that doesn't need any template types.
|
// A utility function for logging that doesn't need any template types.
|
||||||
@@ -104,7 +108,7 @@ inline int CalculateReserve(Iter begin, Iter end) {
|
|||||||
// not ever use a RepeatedField directly; they will use the get-by-index,
|
// not ever use a RepeatedField directly; they will use the get-by-index,
|
||||||
// set-by-index, and add accessors that are generated for all repeated fields.
|
// set-by-index, and add accessors that are generated for all repeated fields.
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
class RepeatedField {
|
class RepeatedField PROTOBUF_FINAL {
|
||||||
public:
|
public:
|
||||||
RepeatedField();
|
RepeatedField();
|
||||||
explicit RepeatedField(Arena* arena);
|
explicit RepeatedField(Arena* arena);
|
||||||
@@ -115,6 +119,11 @@ class RepeatedField {
|
|||||||
|
|
||||||
RepeatedField& operator=(const RepeatedField& other);
|
RepeatedField& operator=(const RepeatedField& other);
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
RepeatedField(RepeatedField&& other) noexcept;
|
||||||
|
RepeatedField& operator=(RepeatedField&& other) noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
int size() const;
|
int size() const;
|
||||||
|
|
||||||
@@ -126,6 +135,8 @@ class RepeatedField {
|
|||||||
|
|
||||||
void Set(int index, const Element& value);
|
void Set(int index, const Element& value);
|
||||||
void Add(const Element& value);
|
void Add(const Element& value);
|
||||||
|
// Appends a new element and return a pointer to it.
|
||||||
|
// The new element is uninitialized if |Element| is a POD type.
|
||||||
Element* Add();
|
Element* Add();
|
||||||
// Remove the last element in the array.
|
// Remove the last element in the array.
|
||||||
void RemoveLast();
|
void RemoveLast();
|
||||||
@@ -138,7 +149,6 @@ class RepeatedField {
|
|||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void MergeFrom(const RepeatedField& other);
|
void MergeFrom(const RepeatedField& other);
|
||||||
void UnsafeMergeFrom(const RepeatedField& other);
|
|
||||||
void CopyFrom(const RepeatedField& other);
|
void CopyFrom(const RepeatedField& other);
|
||||||
|
|
||||||
// Reserve space to expand the field to at least the given size. If the
|
// Reserve space to expand the field to at least the given size. If the
|
||||||
@@ -149,7 +159,11 @@ class RepeatedField {
|
|||||||
void Truncate(int new_size);
|
void Truncate(int new_size);
|
||||||
|
|
||||||
void AddAlreadyReserved(const Element& value);
|
void AddAlreadyReserved(const Element& value);
|
||||||
|
// Appends a new element and return a pointer to it.
|
||||||
|
// The new element is uninitialized if |Element| is a POD type.
|
||||||
|
// Should be called only if Capacity() > Size().
|
||||||
Element* AddAlreadyReserved();
|
Element* AddAlreadyReserved();
|
||||||
|
Element* AddNAlreadyReserved(int elements);
|
||||||
int Capacity() const;
|
int Capacity() const;
|
||||||
|
|
||||||
// Like STL resize. Uses value to fill appended elements.
|
// Like STL resize. Uses value to fill appended elements.
|
||||||
@@ -211,7 +225,11 @@ class RepeatedField {
|
|||||||
|
|
||||||
// Returns the number of bytes used by the repeated field, excluding
|
// Returns the number of bytes used by the repeated field, excluding
|
||||||
// sizeof(*this)
|
// sizeof(*this)
|
||||||
int SpaceUsedExcludingSelf() const;
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
|
|
||||||
|
int SpaceUsedExcludingSelf() const {
|
||||||
|
return internal::ToIntSize(SpaceUsedExcludingSelfLong());
|
||||||
|
}
|
||||||
|
|
||||||
// Removes the element referenced by position.
|
// Removes the element referenced by position.
|
||||||
//
|
//
|
||||||
@@ -233,6 +251,11 @@ class RepeatedField {
|
|||||||
return GetArenaNoVirtual();
|
return GetArenaNoVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For internal use only.
|
||||||
|
//
|
||||||
|
// This is public due to it being called by generated code.
|
||||||
|
inline void InternalSwap(RepeatedField* other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kInitialSize = 0;
|
static const int kInitialSize = 0;
|
||||||
// A note on the representation here (see also comment below for
|
// A note on the representation here (see also comment below for
|
||||||
@@ -263,6 +286,7 @@ class RepeatedField {
|
|||||||
friend class Arena;
|
friend class Arena;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
|
|
||||||
|
|
||||||
// Move the contents of |from| into |to|, possibly clobbering |from| in the
|
// Move the contents of |from| into |to|, possibly clobbering |from| in the
|
||||||
// process. For primitive types this is just a memcpy(), but it could be
|
// process. For primitive types this is just a memcpy(), but it could be
|
||||||
// specialized for non-primitive types to, say, swap each element instead.
|
// specialized for non-primitive types to, say, swap each element instead.
|
||||||
@@ -271,8 +295,6 @@ class RepeatedField {
|
|||||||
// Copy the elements of |from| into |to|.
|
// Copy the elements of |from| into |to|.
|
||||||
void CopyArray(Element* to, const Element* from, int size);
|
void CopyArray(Element* to, const Element* from, int size);
|
||||||
|
|
||||||
inline void InternalSwap(RepeatedField* other);
|
|
||||||
|
|
||||||
// Internal helper expected by Arena methods.
|
// Internal helper expected by Arena methods.
|
||||||
inline Arena* GetArenaNoVirtual() const {
|
inline Arena* GetArenaNoVirtual() const {
|
||||||
return (rep_ == NULL) ? NULL : rep_->arena;
|
return (rep_ == NULL) ? NULL : rep_->arena;
|
||||||
@@ -286,7 +308,7 @@ class RepeatedField {
|
|||||||
Element* e = &rep->elements[0];
|
Element* e = &rep->elements[0];
|
||||||
Element* limit = &rep->elements[size];
|
Element* limit = &rep->elements[size];
|
||||||
for (; e < limit; e++) {
|
for (; e < limit; e++) {
|
||||||
e->Element::~Element();
|
e->~Element();
|
||||||
}
|
}
|
||||||
if (rep->arena == NULL) {
|
if (rep->arena == NULL) {
|
||||||
#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
|
#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
|
||||||
@@ -298,6 +320,9 @@ class RepeatedField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend class internal::WireFormatLite;
|
||||||
|
const Element* unsafe_data() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
@@ -311,12 +336,13 @@ template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// This is a helper template to copy an array of elements effeciently when they
|
// This is a helper template to copy an array of elements efficiently when they
|
||||||
// have a trivial copy constructor, and correctly otherwise. This really
|
// have a trivial copy constructor, and correctly otherwise. This really
|
||||||
// shouldn't be necessary, but our compiler doesn't optimize std::copy very
|
// shouldn't be necessary, but our compiler doesn't optimize std::copy very
|
||||||
// effectively.
|
// effectively.
|
||||||
template <typename Element,
|
template <typename Element,
|
||||||
bool HasTrivialCopy = has_trivial_copy<Element>::value>
|
bool HasTrivialCopy =
|
||||||
|
has_trivial_copy<Element>::value>
|
||||||
struct ElementCopier {
|
struct ElementCopier {
|
||||||
void operator()(Element* to, const Element* from, int array_size);
|
void operator()(Element* to, const Element* from, int array_size);
|
||||||
};
|
};
|
||||||
@@ -330,8 +356,8 @@ namespace internal {
|
|||||||
// exist on the contained type. In particular, we rely on MergeFrom() existing
|
// exist on the contained type. In particular, we rely on MergeFrom() existing
|
||||||
// as a general proxy for the fact that a copy will work, and we also provide a
|
// as a general proxy for the fact that a copy will work, and we also provide a
|
||||||
// specific override for string*.
|
// specific override for string*.
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct TypeImplementsMergeBehavior {
|
struct TypeImplementsMergeBehaviorProbeForMergeFrom {
|
||||||
typedef char HasMerge;
|
typedef char HasMerge;
|
||||||
typedef long HasNoMerge;
|
typedef long HasNoMerge;
|
||||||
|
|
||||||
@@ -350,13 +376,18 @@ struct TypeImplementsMergeBehavior {
|
|||||||
CheckType<U, bool, &U::MergeFrom>*);
|
CheckType<U, bool, &U::MergeFrom>*);
|
||||||
template<typename U> static HasNoMerge Check(...);
|
template<typename U> static HasNoMerge Check(...);
|
||||||
|
|
||||||
// Resovles to either google::protobuf::internal::true_type or google::protobuf::internal::false_type.
|
// Resolves to either google::protobuf::internal::true_type or google::protobuf::internal::false_type.
|
||||||
typedef google::protobuf::internal::integral_constant<bool,
|
typedef google::protobuf::internal::integral_constant<bool,
|
||||||
(sizeof(Check<T>(0)) == sizeof(HasMerge))> type;
|
(sizeof(Check<T>(0)) == sizeof(HasMerge))> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <typename T, typename = void>
|
||||||
struct TypeImplementsMergeBehavior< ::std::string > {
|
struct TypeImplementsMergeBehavior :
|
||||||
|
TypeImplementsMergeBehaviorProbeForMergeFrom<T> {};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct TypeImplementsMergeBehavior< ::std::string> {
|
||||||
typedef google::protobuf::internal::true_type type;
|
typedef google::protobuf::internal::true_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -374,7 +405,7 @@ struct TypeImplementsMergeBehavior< ::std::string > {
|
|||||||
// static void Merge(const Type& from, Type* to);
|
// static void Merge(const Type& from, Type* to);
|
||||||
//
|
//
|
||||||
// // Only needs to be implemented if SpaceUsedExcludingSelf() is called.
|
// // Only needs to be implemented if SpaceUsedExcludingSelf() is called.
|
||||||
// static int SpaceUsed(const Type&);
|
// static int SpaceUsedLong(const Type&);
|
||||||
// };
|
// };
|
||||||
class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
||||||
protected:
|
protected:
|
||||||
@@ -384,10 +415,10 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
friend class GeneratedMessageReflection;
|
friend class GeneratedMessageReflection;
|
||||||
|
|
||||||
// ExtensionSet stores repeated message extensions as
|
// ExtensionSet stores repeated message extensions as
|
||||||
// RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to
|
// RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to implement
|
||||||
// implement SpaceUsed(), and thus need to call SpaceUsedExcludingSelf()
|
// SpaceUsedLong(), and thus need to call SpaceUsedExcludingSelfLong()
|
||||||
// reinterpreting MessageLite as Message. ExtensionSet also needs to make
|
// reinterpreting MessageLite as Message. ExtensionSet also needs to make use
|
||||||
// use of AddFromCleared(), which is not part of the public interface.
|
// of AddFromCleared(), which is not part of the public interface.
|
||||||
friend class ExtensionSet;
|
friend class ExtensionSet;
|
||||||
|
|
||||||
// The MapFieldBase implementation needs to call protected methods directly,
|
// The MapFieldBase implementation needs to call protected methods directly,
|
||||||
@@ -395,6 +426,10 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
// subclass.
|
// subclass.
|
||||||
friend class MapFieldBase;
|
friend class MapFieldBase;
|
||||||
|
|
||||||
|
// The table-driven MergePartialFromCodedStream implementation needs to
|
||||||
|
// operate on RepeatedPtrField<MessageLite>.
|
||||||
|
friend class MergePartialFromCodedStreamHelper;
|
||||||
|
|
||||||
// To parse directly into a proto2 generated class, the upb class GMR_Handlers
|
// To parse directly into a proto2 generated class, the upb class GMR_Handlers
|
||||||
// needs to be able to modify a RepeatedPtrFieldBase directly.
|
// needs to be able to modify a RepeatedPtrFieldBase directly.
|
||||||
friend class upb::google_opensource::GMR_Handlers;
|
friend class upb::google_opensource::GMR_Handlers;
|
||||||
@@ -418,6 +453,11 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
void Delete(int index);
|
void Delete(int index);
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL);
|
typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL);
|
||||||
|
#if LANG_CXX11
|
||||||
|
template <typename TypeHandler>
|
||||||
|
void Add(typename TypeHandler::Type&& value,
|
||||||
|
internal::enable_if<TypeHandler::Moveable>* dummy = NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
void RemoveLast();
|
void RemoveLast();
|
||||||
@@ -443,13 +483,13 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
const typename TypeHandler::Type* const* data() const;
|
const typename TypeHandler::Type* const* data() const;
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
|
||||||
GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(RepeatedPtrFieldBase* other);
|
void Swap(RepeatedPtrFieldBase* other);
|
||||||
|
|
||||||
void SwapElements(int index1, int index2);
|
void SwapElements(int index1, int index2);
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
int SpaceUsedExcludingSelf() const;
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
|
|
||||||
|
|
||||||
// Advanced memory management --------------------------------------
|
// Advanced memory management --------------------------------------
|
||||||
@@ -488,17 +528,15 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
inline void InternalSwap(RepeatedPtrFieldBase* other);
|
inline void InternalSwap(RepeatedPtrFieldBase* other);
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
void AddAllocatedInternal(typename TypeHandler::Type* value,
|
void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::true_type);
|
||||||
google::protobuf::internal::true_type);
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
void AddAllocatedInternal(typename TypeHandler::Type* value,
|
void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::false_type);
|
||||||
google::protobuf::internal::false_type);
|
|
||||||
|
|
||||||
template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE
|
template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
void AddAllocatedSlowWithCopy(typename TypeHandler::Type* value,
|
void AddAllocatedSlowWithCopy(typename TypeHandler::Type* value,
|
||||||
Arena* value_arena,
|
Arena* value_arena,
|
||||||
Arena* my_arena);
|
Arena* my_arena);
|
||||||
template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE
|
template <typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value);
|
void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value);
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
@@ -506,7 +544,7 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::false_type);
|
typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::false_type);
|
||||||
|
|
||||||
template<typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE
|
template<typename TypeHandler> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
void SwapFallback(RepeatedPtrFieldBase* other);
|
void SwapFallback(RepeatedPtrFieldBase* other);
|
||||||
|
|
||||||
inline Arena* GetArenaNoVirtual() const {
|
inline Arena* GetArenaNoVirtual() const {
|
||||||
@@ -563,6 +601,7 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
|
|||||||
// Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
|
// Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.
|
||||||
void** InternalExtend(int extend_amount);
|
void** InternalExtend(int extend_amount);
|
||||||
|
|
||||||
|
friend class AccessorHelper;
|
||||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -570,14 +609,14 @@ template <typename GenericType>
|
|||||||
class GenericTypeHandler {
|
class GenericTypeHandler {
|
||||||
public:
|
public:
|
||||||
typedef GenericType Type;
|
typedef GenericType Type;
|
||||||
|
#if LANG_CXX11
|
||||||
|
static const bool Moveable = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline GenericType* New(Arena* arena) {
|
static inline GenericType* New(Arena* arena) {
|
||||||
return ::google::protobuf::Arena::CreateMaybeMessage<Type>(
|
return ::google::protobuf::Arena::CreateMaybeMessage<Type>(arena);
|
||||||
arena, static_cast<GenericType*>(0));
|
|
||||||
}
|
}
|
||||||
// We force NewFromPrototype() to be non-inline to reduce code size:
|
static inline GenericType* NewFromPrototype(
|
||||||
// else, several other methods get inlined copies of message types'
|
|
||||||
// constructors.
|
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE static GenericType* NewFromPrototype(
|
|
||||||
const GenericType* prototype, ::google::protobuf::Arena* arena = NULL);
|
const GenericType* prototype, ::google::protobuf::Arena* arena = NULL);
|
||||||
static inline void Delete(GenericType* value, Arena* arena) {
|
static inline void Delete(GenericType* value, Arena* arena) {
|
||||||
if (arena == NULL) {
|
if (arena == NULL) {
|
||||||
@@ -592,10 +631,10 @@ class GenericTypeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void Clear(GenericType* value) { value->Clear(); }
|
static inline void Clear(GenericType* value) { value->Clear(); }
|
||||||
GOOGLE_ATTRIBUTE_NOINLINE static void Merge(const GenericType& from,
|
GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE
|
||||||
GenericType* to);
|
static void Merge(const GenericType& from, GenericType* to);
|
||||||
static inline int SpaceUsed(const GenericType& value) {
|
static inline size_t SpaceUsedLong(const GenericType& value) {
|
||||||
return value.SpaceUsed();
|
return value.SpaceUsedLong();
|
||||||
}
|
}
|
||||||
static inline const Type& default_instance() {
|
static inline const Type& default_instance() {
|
||||||
return Type::default_instance();
|
return Type::default_instance();
|
||||||
@@ -613,11 +652,9 @@ void GenericTypeHandler<GenericType>::Merge(const GenericType& from,
|
|||||||
to->MergeFrom(from);
|
to->MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFromPrototype() and Merge() cannot be defined here; if they're declared
|
// NewFromPrototype() and Merge() are not defined inline here, as we will need
|
||||||
// inline the compiler will complain about not matching GOOGLE_ATTRIBUTE_NOINLINE
|
// to do a virtual function dispatch anyways to go from Message* to call
|
||||||
// above, and if not, compilation will result in multiple definitions. These
|
// New/Merge.
|
||||||
// are therefore declared as specializations here and defined in
|
|
||||||
// message_lite.cc.
|
|
||||||
template<>
|
template<>
|
||||||
MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
|
MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
|
||||||
const MessageLite* prototype, google::protobuf::Arena* arena);
|
const MessageLite* prototype, google::protobuf::Arena* arena);
|
||||||
@@ -682,22 +719,23 @@ inline const Message& GenericTypeHandler<Message>::default_instance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HACK: If a class is declared as DLL-exported in MSVC, it insists on
|
class StringTypeHandler {
|
||||||
// generating copies of all its methods -- even inline ones -- to include
|
|
||||||
// in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which
|
|
||||||
// isn't in the lite library, therefore the lite library cannot link if
|
|
||||||
// StringTypeHandler is exported. So, we factor out StringTypeHandlerBase,
|
|
||||||
// export that, then make StringTypeHandler be a subclass which is NOT
|
|
||||||
// exported.
|
|
||||||
// TODO(kenton): Now that StringSpaceUsedExcludingSelf() is in the lite
|
|
||||||
// library, this can be cleaned up.
|
|
||||||
class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
|
|
||||||
public:
|
public:
|
||||||
typedef string Type;
|
typedef string Type;
|
||||||
|
#if LANG_CXX11
|
||||||
|
static const bool Moveable =
|
||||||
|
std::is_move_constructible<Type>::value &&
|
||||||
|
std::is_move_assignable<Type>::value;
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline string* New(Arena* arena) {
|
static inline string* New(Arena* arena) {
|
||||||
return Arena::Create<string>(arena);
|
return Arena::Create<string>(arena);
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
static inline string* New(Arena* arena, string&& value) {
|
||||||
|
return Arena::Create<string>(arena, std::move(value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static inline string* NewFromPrototype(const string*,
|
static inline string* NewFromPrototype(const string*,
|
||||||
::google::protobuf::Arena* arena) {
|
::google::protobuf::Arena* arena) {
|
||||||
return New(arena);
|
return New(arena);
|
||||||
@@ -718,22 +756,17 @@ class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
|
|||||||
static inline const Type& default_instance() {
|
static inline const Type& default_instance() {
|
||||||
return ::google::protobuf::internal::GetEmptyString();
|
return ::google::protobuf::internal::GetEmptyString();
|
||||||
}
|
}
|
||||||
};
|
static size_t SpaceUsedLong(const string& value) {
|
||||||
|
return sizeof(value) + StringSpaceUsedExcludingSelfLong(value);
|
||||||
class StringTypeHandler : public StringTypeHandlerBase {
|
|
||||||
public:
|
|
||||||
static int SpaceUsed(const string& value) {
|
|
||||||
return static_cast<int>(sizeof(value)) + StringSpaceUsedExcludingSelf(value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
// RepeatedPtrField is like RepeatedField, but used for repeated strings or
|
// RepeatedPtrField is like RepeatedField, but used for repeated strings or
|
||||||
// Messages.
|
// Messages.
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase {
|
||||||
public:
|
public:
|
||||||
RepeatedPtrField();
|
RepeatedPtrField();
|
||||||
explicit RepeatedPtrField(::google::protobuf::Arena* arena);
|
explicit RepeatedPtrField(::google::protobuf::Arena* arena);
|
||||||
@@ -745,12 +778,20 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
|
|
||||||
RepeatedPtrField& operator=(const RepeatedPtrField& other);
|
RepeatedPtrField& operator=(const RepeatedPtrField& other);
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
RepeatedPtrField(RepeatedPtrField&& other) noexcept;
|
||||||
|
RepeatedPtrField& operator=(RepeatedPtrField&& other) noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
int size() const;
|
int size() const;
|
||||||
|
|
||||||
const Element& Get(int index) const;
|
const Element& Get(int index) const;
|
||||||
Element* Mutable(int index);
|
Element* Mutable(int index);
|
||||||
Element* Add();
|
Element* Add();
|
||||||
|
#if LANG_CXX11
|
||||||
|
void Add(Element&& value);
|
||||||
|
#endif
|
||||||
|
|
||||||
const Element& operator[](int index) const { return Get(index); }
|
const Element& operator[](int index) const { return Get(index); }
|
||||||
Element& operator[](int index) { return *Mutable(index); }
|
Element& operator[](int index) { return *Mutable(index); }
|
||||||
@@ -766,7 +807,6 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void MergeFrom(const RepeatedPtrField& other);
|
void MergeFrom(const RepeatedPtrField& other);
|
||||||
void UnsafeMergeFrom(const RepeatedPtrField& other) { MergeFrom(other); }
|
|
||||||
void CopyFrom(const RepeatedPtrField& other);
|
void CopyFrom(const RepeatedPtrField& other);
|
||||||
|
|
||||||
// Reserve space to expand the field to at least the given size. This only
|
// Reserve space to expand the field to at least the given size. This only
|
||||||
@@ -830,10 +870,11 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
|
|
||||||
// Custom STL-like iterator that iterates over and returns the underlying
|
// Custom STL-like iterator that iterates over and returns the underlying
|
||||||
// pointers to Element rather than Element itself.
|
// pointers to Element rather than Element itself.
|
||||||
typedef internal::RepeatedPtrOverPtrsIterator<Element, void*>
|
typedef internal::RepeatedPtrOverPtrsIterator<Element*, void*>
|
||||||
pointer_iterator;
|
pointer_iterator;
|
||||||
typedef internal::RepeatedPtrOverPtrsIterator<const Element, const void*>
|
typedef internal::RepeatedPtrOverPtrsIterator<const Element* const,
|
||||||
const_pointer_iterator;
|
const void* const>
|
||||||
|
const_pointer_iterator;
|
||||||
pointer_iterator pointer_begin();
|
pointer_iterator pointer_begin();
|
||||||
const_pointer_iterator pointer_begin() const;
|
const_pointer_iterator pointer_begin() const;
|
||||||
pointer_iterator pointer_end();
|
pointer_iterator pointer_end();
|
||||||
@@ -841,7 +882,11 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
|
|
||||||
// Returns (an estimate of) the number of bytes used by the repeated field,
|
// Returns (an estimate of) the number of bytes used by the repeated field,
|
||||||
// excluding sizeof(*this).
|
// excluding sizeof(*this).
|
||||||
int SpaceUsedExcludingSelf() const;
|
size_t SpaceUsedExcludingSelfLong() const;
|
||||||
|
|
||||||
|
int SpaceUsedExcludingSelf() const {
|
||||||
|
return internal::ToIntSize(SpaceUsedExcludingSelfLong());
|
||||||
|
}
|
||||||
|
|
||||||
// Advanced memory management --------------------------------------
|
// Advanced memory management --------------------------------------
|
||||||
// When hardcore memory management becomes necessary -- as it sometimes
|
// When hardcore memory management becomes necessary -- as it sometimes
|
||||||
@@ -873,10 +918,10 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
// RepeatedPtrField.
|
// RepeatedPtrField.
|
||||||
// It is also useful in legacy code that uses temporary ownership to avoid
|
// It is also useful in legacy code that uses temporary ownership to avoid
|
||||||
// copies. Example:
|
// copies. Example:
|
||||||
// RepeatedPtrField<T> temp_field;
|
// RepeatedPtrField<T> temp_field;
|
||||||
// temp_field.AddAllocated(new T);
|
// temp_field.AddAllocated(new T);
|
||||||
// ... // Do something with temp_field
|
// ... // Do something with temp_field
|
||||||
// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
|
// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
|
||||||
// If you put temp_field on the arena this fails, because the ownership
|
// If you put temp_field on the arena this fails, because the ownership
|
||||||
// transfers to the arena at the "AddAllocated" call and is not released
|
// transfers to the arena at the "AddAllocated" call and is not released
|
||||||
// anymore causing a double delete. UnsafeArenaAddAllocated prevents this.
|
// anymore causing a double delete. UnsafeArenaAddAllocated prevents this.
|
||||||
@@ -958,17 +1003,18 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
|
|||||||
return GetArenaNoVirtual();
|
return GetArenaNoVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
// For internal use only.
|
||||||
// Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only
|
//
|
||||||
// subclass it in one place as a hack for compatibility with proto1. The
|
// This is public due to it being called by generated code.
|
||||||
// subclass needs to know about TypeHandler in order to call protected
|
using RepeatedPtrFieldBase::InternalSwap;
|
||||||
// methods on RepeatedPtrFieldBase.
|
|
||||||
|
private:
|
||||||
|
// Note: RepeatedPtrField SHOULD NOT be subclassed by users.
|
||||||
class TypeHandler;
|
class TypeHandler;
|
||||||
|
|
||||||
// Internal arena accessor expected by helpers in Arena.
|
// Internal arena accessor expected by helpers in Arena.
|
||||||
inline Arena* GetArenaNoVirtual() const;
|
inline Arena* GetArenaNoVirtual() const;
|
||||||
|
|
||||||
private:
|
|
||||||
// Implementations for ExtractSubrange(). The copying behavior must be
|
// Implementations for ExtractSubrange(). The copying behavior must be
|
||||||
// included only if the type supports the necessary operations (e.g.,
|
// included only if the type supports the necessary operations (e.g.,
|
||||||
// MergeFrom()), so we must resolve this at compile time. ExtractSubrange()
|
// MergeFrom()), so we must resolve this at compile time. ExtractSubrange()
|
||||||
@@ -997,13 +1043,13 @@ inline RepeatedField<Element>::RepeatedField(Arena* arena)
|
|||||||
: current_size_(0),
|
: current_size_(0),
|
||||||
total_size_(0),
|
total_size_(0),
|
||||||
rep_(NULL) {
|
rep_(NULL) {
|
||||||
// In case arena is NULL, then we do not create rep_, as code has an invariant
|
// In case arena is NULL, then we do not create rep_, as code has an invariant
|
||||||
// `rep_ == NULL then arena == NULL`.
|
// `rep_ == NULL then arena == NULL`.
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
rep_ = reinterpret_cast<Rep*>(
|
rep_ = reinterpret_cast<Rep*>(
|
||||||
::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
|
::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
|
||||||
rep_->arena = arena;
|
rep_->arena = arena;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
@@ -1011,7 +1057,12 @@ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
|
|||||||
: current_size_(0),
|
: current_size_(0),
|
||||||
total_size_(0),
|
total_size_(0),
|
||||||
rep_(NULL) {
|
rep_(NULL) {
|
||||||
CopyFrom(other);
|
if (other.current_size_ != 0) {
|
||||||
|
Reserve(other.current_size_);
|
||||||
|
CopyArray(rep_->elements,
|
||||||
|
other.rep_->elements, other.current_size_);
|
||||||
|
current_size_ = other.current_size_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
@@ -1048,6 +1099,37 @@ RepeatedField<Element>::operator=(const RepeatedField& other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
inline RepeatedField<Element>::RepeatedField(RepeatedField&& other) noexcept
|
||||||
|
: RepeatedField() {
|
||||||
|
// We don't just call Swap(&other) here because it would perform 3 copies if
|
||||||
|
// the two fields are on different arenas.
|
||||||
|
if (other.GetArenaNoVirtual()) {
|
||||||
|
CopyFrom(other);
|
||||||
|
} else {
|
||||||
|
InternalSwap(&other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
inline RepeatedField<Element>& RepeatedField<Element>::operator=(
|
||||||
|
RepeatedField&& other) noexcept {
|
||||||
|
// We don't just call Swap(&other) here because it would perform 3 copies if
|
||||||
|
// the two fields are on different arenas.
|
||||||
|
if (this != &other) {
|
||||||
|
if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) {
|
||||||
|
CopyFrom(other);
|
||||||
|
} else {
|
||||||
|
InternalSwap(&other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LANG_CXX11
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline bool RepeatedField<Element>::empty() const {
|
inline bool RepeatedField<Element>::empty() const {
|
||||||
return current_size_ == 0;
|
return current_size_ == 0;
|
||||||
@@ -1075,6 +1157,14 @@ inline Element* RepeatedField<Element>::AddAlreadyReserved() {
|
|||||||
return &rep_->elements[current_size_++];
|
return &rep_->elements[current_size_++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Element>
|
||||||
|
inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
|
||||||
|
GOOGLE_DCHECK_LE(current_size_ + elements, total_size_);
|
||||||
|
Element* ret = &rep_->elements[current_size_];
|
||||||
|
current_size_ += elements;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
|
inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
|
||||||
GOOGLE_DCHECK_GE(new_size, 0);
|
GOOGLE_DCHECK_GE(new_size, 0);
|
||||||
@@ -1152,7 +1242,8 @@ inline void RepeatedField<Element>::Clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) {
|
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
|
||||||
|
GOOGLE_DCHECK_NE(&other, this);
|
||||||
if (other.current_size_ != 0) {
|
if (other.current_size_ != 0) {
|
||||||
Reserve(current_size_ + other.current_size_);
|
Reserve(current_size_ + other.current_size_);
|
||||||
CopyArray(rep_->elements + current_size_,
|
CopyArray(rep_->elements + current_size_,
|
||||||
@@ -1161,12 +1252,6 @@ inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
|
||||||
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
|
|
||||||
GOOGLE_CHECK_NE(&other, this);
|
|
||||||
UnsafeMergeFrom(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {
|
inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {
|
||||||
if (&other == this) return;
|
if (&other == this) return;
|
||||||
@@ -1200,9 +1285,17 @@ inline const Element* RepeatedField<Element>::data() const {
|
|||||||
return rep_ ? rep_->elements : NULL;
|
return rep_ ? rep_->elements : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
inline const Element* RepeatedField<Element>::unsafe_data() const {
|
||||||
|
GOOGLE_DCHECK(rep_);
|
||||||
|
return rep_->elements;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
|
inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
|
||||||
|
GOOGLE_DCHECK(this != other);
|
||||||
|
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
|
||||||
|
|
||||||
std::swap(rep_, other->rep_);
|
std::swap(rep_, other->rep_);
|
||||||
std::swap(current_size_, other->current_size_);
|
std::swap(current_size_, other->current_size_);
|
||||||
std::swap(total_size_, other->total_size_);
|
std::swap(total_size_, other->total_size_);
|
||||||
@@ -1211,7 +1304,7 @@ inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
|
|||||||
template <typename Element>
|
template <typename Element>
|
||||||
void RepeatedField<Element>::Swap(RepeatedField* other) {
|
void RepeatedField<Element>::Swap(RepeatedField* other) {
|
||||||
if (this == other) return;
|
if (this == other) return;
|
||||||
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
|
||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
} else {
|
} else {
|
||||||
RepeatedField<Element> temp(other->GetArenaNoVirtual());
|
RepeatedField<Element> temp(other->GetArenaNoVirtual());
|
||||||
@@ -1224,7 +1317,6 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
|
|||||||
template <typename Element>
|
template <typename Element>
|
||||||
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
|
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
|
||||||
if (this == other) return;
|
if (this == other) return;
|
||||||
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
|
|
||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,9 +1358,8 @@ RepeatedField<Element>::cend() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline int RepeatedField<Element>::SpaceUsedExcludingSelf() const {
|
inline size_t RepeatedField<Element>::SpaceUsedExcludingSelfLong() const {
|
||||||
return rep_ ?
|
return rep_ ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0;
|
||||||
(total_size_ * sizeof(Element) + kRepHeaderSize) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
|
// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
|
||||||
@@ -1280,11 +1371,11 @@ void RepeatedField<Element>::Reserve(int new_size) {
|
|||||||
Arena* arena = GetArenaNoVirtual();
|
Arena* arena = GetArenaNoVirtual();
|
||||||
new_size = std::max(google::protobuf::internal::kMinRepeatedFieldAllocationSize,
|
new_size = std::max(google::protobuf::internal::kMinRepeatedFieldAllocationSize,
|
||||||
std::max(total_size_ * 2, new_size));
|
std::max(total_size_ * 2, new_size));
|
||||||
GOOGLE_CHECK_LE(static_cast<size_t>(new_size),
|
GOOGLE_DCHECK_LE(
|
||||||
(std::numeric_limits<size_t>::max() - kRepHeaderSize) /
|
static_cast<size_t>(new_size),
|
||||||
sizeof(Element))
|
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
|
||||||
<< "Requested size is too large to fit into size_t.";
|
<< "Requested size is too large to fit into size_t.";
|
||||||
size_t bytes = kRepHeaderSize + sizeof(Element) * new_size;
|
size_t bytes = kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size);
|
||||||
if (arena == NULL) {
|
if (arena == NULL) {
|
||||||
rep_ = static_cast<Rep*>(::operator new(bytes));
|
rep_ = static_cast<Rep*>(::operator new(bytes));
|
||||||
} else {
|
} else {
|
||||||
@@ -1306,7 +1397,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
|
|||||||
Element* e = &rep_->elements[0];
|
Element* e = &rep_->elements[0];
|
||||||
Element* limit = &rep_->elements[total_size_];
|
Element* limit = &rep_->elements[total_size_];
|
||||||
for (; e < limit; e++) {
|
for (; e < limit; e++) {
|
||||||
new (e) Element();
|
new (e) Element;
|
||||||
}
|
}
|
||||||
if (current_size_ > 0) {
|
if (current_size_ > 0) {
|
||||||
MoveArray(rep_->elements, old_rep->elements, current_size_);
|
MoveArray(rep_->elements, old_rep->elements, current_size_);
|
||||||
@@ -1348,7 +1439,7 @@ void ElementCopier<Element, HasTrivialCopy>::operator()(
|
|||||||
template <typename Element>
|
template <typename Element>
|
||||||
struct ElementCopier<Element, true> {
|
struct ElementCopier<Element, true> {
|
||||||
void operator()(Element* to, const Element* from, int array_size) {
|
void operator()(Element* to, const Element* from, int array_size) {
|
||||||
memcpy(to, from, array_size * sizeof(Element));
|
memcpy(to, from, static_cast<size_t>(array_size) * sizeof(Element));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1464,6 +1555,25 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
template <typename TypeHandler>
|
||||||
|
inline void RepeatedPtrFieldBase::Add(
|
||||||
|
typename TypeHandler::Type&& value,
|
||||||
|
internal::enable_if<TypeHandler::Moveable>*) {
|
||||||
|
if (rep_ != NULL && current_size_ < rep_->allocated_size) {
|
||||||
|
*cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!rep_ || rep_->allocated_size == total_size_) {
|
||||||
|
Reserve(total_size_ + 1);
|
||||||
|
}
|
||||||
|
++rep_->allocated_size;
|
||||||
|
typename TypeHandler::Type* result =
|
||||||
|
TypeHandler::New(arena_, std::move(value));
|
||||||
|
rep_->elements[current_size_++] = result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
inline void RepeatedPtrFieldBase::RemoveLast() {
|
inline void RepeatedPtrFieldBase::RemoveLast() {
|
||||||
GOOGLE_DCHECK_GT(current_size_, 0);
|
GOOGLE_DCHECK_GT(current_size_, 0);
|
||||||
@@ -1580,11 +1690,11 @@ inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TypeHandler>
|
template <typename TypeHandler>
|
||||||
inline int RepeatedPtrFieldBase::SpaceUsedExcludingSelf() const {
|
inline size_t RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() const {
|
||||||
int allocated_bytes = total_size_ * sizeof(void*);
|
size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*);
|
||||||
if (rep_ != NULL) {
|
if (rep_ != NULL) {
|
||||||
for (int i = 0; i < rep_->allocated_size; ++i) {
|
for (int i = 0; i < rep_->allocated_size; ++i) {
|
||||||
allocated_bytes += TypeHandler::SpaceUsed(
|
allocated_bytes += TypeHandler::SpaceUsedLong(
|
||||||
*cast<TypeHandler>(rep_->elements[i]));
|
*cast<TypeHandler>(rep_->elements[i]));
|
||||||
}
|
}
|
||||||
allocated_bytes += kRepHeaderSize;
|
allocated_bytes += kRepHeaderSize;
|
||||||
@@ -1623,7 +1733,6 @@ void RepeatedPtrFieldBase::AddAllocatedInternal(
|
|||||||
elems[current_size_] = value;
|
elems[current_size_] = value;
|
||||||
current_size_ = current_size_ + 1;
|
current_size_ = current_size_ + 1;
|
||||||
rep_->allocated_size = rep_->allocated_size + 1;
|
rep_->allocated_size = rep_->allocated_size + 1;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
AddAllocatedSlowWithCopy<TypeHandler>(
|
AddAllocatedSlowWithCopy<TypeHandler>(
|
||||||
value, TypeHandler::GetArena(value), arena);
|
value, TypeHandler::GetArena(value), arena);
|
||||||
@@ -1670,7 +1779,6 @@ void RepeatedPtrFieldBase::AddAllocatedInternal(
|
|||||||
elems[current_size_] = value;
|
elems[current_size_] = value;
|
||||||
current_size_ = current_size_ + 1;
|
current_size_ = current_size_ + 1;
|
||||||
++rep_->allocated_size;
|
++rep_->allocated_size;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
UnsafeArenaAddAllocated<TypeHandler>(value);
|
UnsafeArenaAddAllocated<TypeHandler>(value);
|
||||||
}
|
}
|
||||||
@@ -1793,7 +1901,6 @@ class RepeatedPtrField<string>::TypeHandler
|
|||||||
: public internal::StringTypeHandler {
|
: public internal::StringTypeHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline RepeatedPtrField<Element>::RepeatedPtrField()
|
inline RepeatedPtrField<Element>::RepeatedPtrField()
|
||||||
: RepeatedPtrFieldBase() {}
|
: RepeatedPtrFieldBase() {}
|
||||||
@@ -1806,7 +1913,7 @@ template <typename Element>
|
|||||||
inline RepeatedPtrField<Element>::RepeatedPtrField(
|
inline RepeatedPtrField<Element>::RepeatedPtrField(
|
||||||
const RepeatedPtrField& other)
|
const RepeatedPtrField& other)
|
||||||
: RepeatedPtrFieldBase() {
|
: RepeatedPtrFieldBase() {
|
||||||
CopyFrom(other);
|
MergeFrom(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
@@ -1835,6 +1942,38 @@ inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=(
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
inline RepeatedPtrField<Element>::RepeatedPtrField(
|
||||||
|
RepeatedPtrField&& other) noexcept
|
||||||
|
: RepeatedPtrField() {
|
||||||
|
// We don't just call Swap(&other) here because it would perform 3 copies if
|
||||||
|
// the two fields are on different arenas.
|
||||||
|
if (other.GetArenaNoVirtual()) {
|
||||||
|
CopyFrom(other);
|
||||||
|
} else {
|
||||||
|
InternalSwap(&other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=(
|
||||||
|
RepeatedPtrField&& other) noexcept {
|
||||||
|
// We don't just call Swap(&other) here because it would perform 3 copies if
|
||||||
|
// the two fields are on different arenas.
|
||||||
|
if (this != &other) {
|
||||||
|
if (this->GetArenaNoVirtual() != other.GetArenaNoVirtual()) {
|
||||||
|
CopyFrom(other);
|
||||||
|
} else {
|
||||||
|
InternalSwap(&other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LANG_CXX11
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline bool RepeatedPtrField<Element>::empty() const {
|
inline bool RepeatedPtrField<Element>::empty() const {
|
||||||
return RepeatedPtrFieldBase::empty();
|
return RepeatedPtrFieldBase::empty();
|
||||||
@@ -1861,6 +2000,13 @@ inline Element* RepeatedPtrField<Element>::Add() {
|
|||||||
return RepeatedPtrFieldBase::Add<TypeHandler>();
|
return RepeatedPtrFieldBase::Add<TypeHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LANG_CXX11
|
||||||
|
template <typename Element>
|
||||||
|
inline void RepeatedPtrField<Element>::Add(Element&& value) {
|
||||||
|
RepeatedPtrFieldBase::Add<TypeHandler>(std::move(value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline void RepeatedPtrField<Element>::RemoveLast() {
|
inline void RepeatedPtrField<Element>::RemoveLast() {
|
||||||
RepeatedPtrFieldBase::RemoveLast<TypeHandler>();
|
RepeatedPtrFieldBase::RemoveLast<TypeHandler>();
|
||||||
@@ -2003,7 +2149,6 @@ inline void RepeatedPtrField<Element>::Swap(RepeatedPtrField* other) {
|
|||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
|
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
|
||||||
RepeatedPtrField* other) {
|
RepeatedPtrField* other) {
|
||||||
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
|
|
||||||
if (this == other)
|
if (this == other)
|
||||||
return;
|
return;
|
||||||
RepeatedPtrFieldBase::InternalSwap(other);
|
RepeatedPtrFieldBase::InternalSwap(other);
|
||||||
@@ -2020,8 +2165,8 @@ inline Arena* RepeatedPtrField<Element>::GetArenaNoVirtual() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline int RepeatedPtrField<Element>::SpaceUsedExcludingSelf() const {
|
inline size_t RepeatedPtrField<Element>::SpaceUsedExcludingSelfLong() const {
|
||||||
return RepeatedPtrFieldBase::SpaceUsedExcludingSelf<TypeHandler>();
|
return RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong<TypeHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
@@ -2113,7 +2258,7 @@ class RepeatedPtrIterator
|
|||||||
: it_(other.it_) {
|
: it_(other.it_) {
|
||||||
// Force a compiler error if the other type is not convertible to ours.
|
// Force a compiler error if the other type is not convertible to ours.
|
||||||
if (false) {
|
if (false) {
|
||||||
implicit_cast<Element*, OtherElement*>(0);
|
implicit_cast<Element*>(static_cast<OtherElement*>(NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2179,18 +2324,17 @@ class RepeatedPtrIterator
|
|||||||
// the array.
|
// the array.
|
||||||
// The VoidPtr template parameter holds the type-agnostic pointer value
|
// The VoidPtr template parameter holds the type-agnostic pointer value
|
||||||
// referenced by the iterator. It should either be "void *" for a mutable
|
// referenced by the iterator. It should either be "void *" for a mutable
|
||||||
// iterator, or "const void *" for a constant iterator.
|
// iterator, or "const void* const" for a constant iterator.
|
||||||
template<typename Element, typename VoidPtr>
|
template <typename Element, typename VoidPtr>
|
||||||
class RepeatedPtrOverPtrsIterator
|
class RepeatedPtrOverPtrsIterator
|
||||||
: public std::iterator<std::random_access_iterator_tag, Element*> {
|
: public std::iterator<std::random_access_iterator_tag, Element> {
|
||||||
public:
|
public:
|
||||||
typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
|
typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
|
||||||
typedef std::iterator<
|
typedef std::iterator<std::random_access_iterator_tag, Element> superclass;
|
||||||
std::random_access_iterator_tag, Element*> superclass;
|
|
||||||
|
|
||||||
// Shadow the value_type in std::iterator<> because const_iterator::value_type
|
// Shadow the value_type in std::iterator<> because const_iterator::value_type
|
||||||
// needs to be T, not const T.
|
// needs to be T, not const T.
|
||||||
typedef typename remove_const<Element*>::type value_type;
|
typedef typename remove_const<Element>::type value_type;
|
||||||
|
|
||||||
// Let the compiler know that these are type names, so we don't have to
|
// Let the compiler know that these are type names, so we don't have to
|
||||||
// write "typename" in front of them everywhere.
|
// write "typename" in front of them everywhere.
|
||||||
@@ -2202,7 +2346,7 @@ class RepeatedPtrOverPtrsIterator
|
|||||||
explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {}
|
explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {}
|
||||||
|
|
||||||
// dereferenceable
|
// dereferenceable
|
||||||
reference operator*() const { return *reinterpret_cast<Element**>(it_); }
|
reference operator*() const { return *reinterpret_cast<Element*>(it_); }
|
||||||
pointer operator->() const { return &(operator*()); }
|
pointer operator->() const { return &(operator*()); }
|
||||||
|
|
||||||
// {inc,dec}rementable
|
// {inc,dec}rementable
|
||||||
@@ -2258,6 +2402,9 @@ class RepeatedPtrOverPtrsIterator
|
|||||||
};
|
};
|
||||||
|
|
||||||
void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) {
|
void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) {
|
||||||
|
GOOGLE_DCHECK(this != other);
|
||||||
|
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
|
||||||
|
|
||||||
std::swap(rep_, other->rep_);
|
std::swap(rep_, other->rep_);
|
||||||
std::swap(current_size_, other->current_size_);
|
std::swap(current_size_, other->current_size_);
|
||||||
std::swap(total_size_, other->total_size_);
|
std::swap(total_size_, other->total_size_);
|
||||||
@@ -2304,7 +2451,7 @@ RepeatedPtrField<Element>::pointer_begin() {
|
|||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline typename RepeatedPtrField<Element>::const_pointer_iterator
|
inline typename RepeatedPtrField<Element>::const_pointer_iterator
|
||||||
RepeatedPtrField<Element>::pointer_begin() const {
|
RepeatedPtrField<Element>::pointer_begin() const {
|
||||||
return const_pointer_iterator(const_cast<const void**>(raw_mutable_data()));
|
return const_pointer_iterator(const_cast<const void* const*>(raw_data()));
|
||||||
}
|
}
|
||||||
template <typename Element>
|
template <typename Element>
|
||||||
inline typename RepeatedPtrField<Element>::pointer_iterator
|
inline typename RepeatedPtrField<Element>::pointer_iterator
|
||||||
@@ -2315,7 +2462,7 @@ template <typename Element>
|
|||||||
inline typename RepeatedPtrField<Element>::const_pointer_iterator
|
inline typename RepeatedPtrField<Element>::const_pointer_iterator
|
||||||
RepeatedPtrField<Element>::pointer_end() const {
|
RepeatedPtrField<Element>::pointer_end() const {
|
||||||
return const_pointer_iterator(
|
return const_pointer_iterator(
|
||||||
const_cast<const void**>(raw_mutable_data() + size()));
|
const_cast<const void* const*>(raw_data() + size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2372,6 +2519,12 @@ template<typename T> class RepeatedPtrFieldBackInsertIterator
|
|||||||
*field_->Add() = *ptr_to_value;
|
*field_->Add() = *ptr_to_value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
RepeatedPtrFieldBackInsertIterator<T>& operator=(T&& value) {
|
||||||
|
*field_->Add() = std::move(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
RepeatedPtrFieldBackInsertIterator<T>& operator*() {
|
RepeatedPtrFieldBackInsertIterator<T>& operator*() {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -2483,10 +2636,10 @@ AllocatedRepeatedPtrFieldBackInserter(
|
|||||||
// UnsafeArenaAddAllocated instead of AddAllocated.
|
// UnsafeArenaAddAllocated instead of AddAllocated.
|
||||||
// This is slightly faster if that matters. It is also useful in legacy code
|
// This is slightly faster if that matters. It is also useful in legacy code
|
||||||
// that uses temporary ownership to avoid copies. Example:
|
// that uses temporary ownership to avoid copies. Example:
|
||||||
// RepeatedPtrField<T> temp_field;
|
// RepeatedPtrField<T> temp_field;
|
||||||
// temp_field.AddAllocated(new T);
|
// temp_field.AddAllocated(new T);
|
||||||
// ... // Do something with temp_field
|
// ... // Do something with temp_field
|
||||||
// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
|
// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
|
||||||
// If you put temp_field on the arena this fails, because the ownership
|
// If you put temp_field on the arena this fails, because the ownership
|
||||||
// transfers to the arena at the "AddAllocated" call and is not released anymore
|
// transfers to the arena at the "AddAllocated" call and is not released anymore
|
||||||
// causing a double delete. Using UnsafeArenaAddAllocated prevents this.
|
// causing a double delete. Using UnsafeArenaAddAllocated prevents this.
|
||||||
|
|||||||
+162
-202
@@ -1,7 +1,6 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: google/protobuf/source_context.proto
|
// source: google/protobuf/source_context.proto
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include <google/protobuf/source_context.pb.h>
|
#include <google/protobuf/source_context.pb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -15,136 +14,135 @@
|
|||||||
#include <google/protobuf/generated_message_reflection.h>
|
#include <google/protobuf/generated_message_reflection.h>
|
||||||
#include <google/protobuf/reflection_ops.h>
|
#include <google/protobuf/reflection_ops.h>
|
||||||
#include <google/protobuf/wire_format.h>
|
#include <google/protobuf/wire_format.h>
|
||||||
|
// This is a temporary google only hack
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
#include "third_party/protobuf/version.h"
|
||||||
|
#endif
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
class SourceContextDefaultTypeInternal {
|
||||||
|
public:
|
||||||
|
::google::protobuf::internal::ExplicitlyConstructed<SourceContext>
|
||||||
|
_instance;
|
||||||
|
} _SourceContext_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
|
||||||
|
void InitDefaultsSourceContextImpl() {
|
||||||
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
|
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
|
||||||
|
#else
|
||||||
|
::google::protobuf::internal::InitProtobufDefaults();
|
||||||
|
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
|
||||||
|
{
|
||||||
|
void* ptr = &::google::protobuf::_SourceContext_default_instance_;
|
||||||
|
new (ptr) ::google::protobuf::SourceContext();
|
||||||
|
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
|
||||||
|
}
|
||||||
|
::google::protobuf::SourceContext::InitAsDefaultInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDefaultsSourceContext() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsSourceContextImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
::google::protobuf::Metadata file_level_metadata[1];
|
||||||
|
|
||||||
|
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
~0u, // no _has_bits_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, _internal_metadata_),
|
||||||
|
~0u, // no _extensions_
|
||||||
|
~0u, // no _oneof_case_
|
||||||
|
~0u, // no _weak_field_map_
|
||||||
|
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::SourceContext, file_name_),
|
||||||
|
};
|
||||||
|
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
{ 0, -1, sizeof(::google::protobuf::SourceContext)},
|
||||||
|
};
|
||||||
|
|
||||||
|
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||||
|
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_SourceContext_default_instance_),
|
||||||
|
};
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptors() {
|
||||||
|
AddDescriptors();
|
||||||
|
::google::protobuf::MessageFactory* factory = NULL;
|
||||||
|
AssignDescriptors(
|
||||||
|
"google/protobuf/source_context.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||||
|
file_level_metadata, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_AssignDescriptorsOnce() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
|
||||||
|
void protobuf_RegisterTypes(const ::std::string&) {
|
||||||
|
protobuf_AssignDescriptorsOnce();
|
||||||
|
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptorsImpl() {
|
||||||
|
InitDefaults();
|
||||||
|
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
|
"\n$google/protobuf/source_context.proto\022\017"
|
||||||
|
"google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
|
||||||
|
"_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou"
|
||||||
|
"rceContextProtoP\001ZAgoogle.golang.org/gen"
|
||||||
|
"proto/protobuf/source_context;source_con"
|
||||||
|
"text\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTy"
|
||||||
|
"pesb\006proto3"
|
||||||
|
};
|
||||||
|
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||||
|
descriptor, 251);
|
||||||
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
|
"google/protobuf/source_context.proto", &protobuf_RegisterTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDescriptors() {
|
||||||
|
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||||
|
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||||
|
}
|
||||||
|
// Force AddDescriptors() to be called at dynamic initialization time.
|
||||||
|
struct StaticDescriptorInitializer {
|
||||||
|
StaticDescriptorInitializer() {
|
||||||
|
AddDescriptors();
|
||||||
|
}
|
||||||
|
} static_descriptor_initializer;
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
SourceContext_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"google/protobuf/source_context.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
SourceContext_descriptor_ = file->message_type(0);
|
|
||||||
static const int SourceContext_offsets_[1] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),
|
|
||||||
};
|
|
||||||
SourceContext_reflection_ =
|
|
||||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
|
||||||
SourceContext_descriptor_,
|
|
||||||
SourceContext::internal_default_instance(),
|
|
||||||
SourceContext_offsets_,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
sizeof(SourceContext),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
SourceContext_descriptor_, SourceContext::internal_default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() {
|
|
||||||
SourceContext_default_instance_.Shutdown();
|
|
||||||
delete SourceContext_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
::google::protobuf::internal::GetEmptyString();
|
|
||||||
SourceContext_default_instance_.DefaultConstruct();
|
|
||||||
SourceContext_default_instance_.get_mutable()->InitAsDefaultInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_);
|
|
||||||
void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_,
|
|
||||||
&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
|
|
||||||
}
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n$google/protobuf/source_context.proto\022\017"
|
|
||||||
"google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
|
|
||||||
"_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour"
|
|
||||||
"ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf"
|
|
||||||
".WellKnownTypesb\006proto3", 183);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"google/protobuf/source_context.proto", &protobuf_RegisterTypes);
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_);
|
|
||||||
void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_,
|
|
||||||
&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
|
|
||||||
}
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto {
|
|
||||||
StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() {
|
|
||||||
protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
|
|
||||||
static void MergeFromFail(int line) {
|
|
||||||
::google::protobuf::internal::MergeFromFail(__FILE__, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
void SourceContext::InitAsDefaultInstance() {
|
||||||
|
}
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
const int SourceContext::kFileNameFieldNumber;
|
const int SourceContext::kFileNameFieldNumber;
|
||||||
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
|
|
||||||
SourceContext::SourceContext()
|
SourceContext::SourceContext()
|
||||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||||
if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||||
|
::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext();
|
||||||
|
}
|
||||||
SharedCtor();
|
SharedCtor();
|
||||||
// @@protoc_insertion_point(constructor:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(constructor:google.protobuf.SourceContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceContext::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceContext::SourceContext(const SourceContext& from)
|
SourceContext::SourceContext(const SourceContext& from)
|
||||||
: ::google::protobuf::Message(),
|
: ::google::protobuf::Message(),
|
||||||
_internal_metadata_(NULL) {
|
_internal_metadata_(NULL),
|
||||||
SharedCtor();
|
_cached_size_(0) {
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
|
file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
if (from.file_name().size() > 0) {
|
||||||
|
file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,17 +166,15 @@ void SourceContext::SetCachedSize(int size) const {
|
|||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||||
}
|
}
|
||||||
const ::google::protobuf::Descriptor* SourceContext::descriptor() {
|
const ::google::protobuf::Descriptor* SourceContext::descriptor() {
|
||||||
protobuf_AssignDescriptorsOnce();
|
::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
return SourceContext_descriptor_;
|
return ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SourceContext& SourceContext::default_instance() {
|
const SourceContext& SourceContext::default_instance() {
|
||||||
protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContext();
|
||||||
return *internal_default_instance();
|
return *internal_default_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_;
|
|
||||||
|
|
||||||
SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {
|
SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {
|
||||||
SourceContext* n = new SourceContext;
|
SourceContext* n = new SourceContext;
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
@@ -189,7 +185,12 @@ SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {
|
|||||||
|
|
||||||
void SourceContext::Clear() {
|
void SourceContext::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext)
|
||||||
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
_internal_metadata_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourceContext::MergePartialFromCodedStream(
|
bool SourceContext::MergePartialFromCodedStream(
|
||||||
@@ -198,34 +199,33 @@ bool SourceContext::MergePartialFromCodedStream(
|
|||||||
::google::protobuf::uint32 tag;
|
::google::protobuf::uint32 tag;
|
||||||
// @@protoc_insertion_point(parse_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(parse_start:google.protobuf.SourceContext)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
|
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
|
||||||
tag = p.first;
|
tag = p.first;
|
||||||
if (!p.second) goto handle_unusual;
|
if (!p.second) goto handle_unusual;
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||||
// optional string file_name = 1;
|
// string file_name = 1;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (tag == 10) {
|
if (static_cast< ::google::protobuf::uint8>(tag) ==
|
||||||
|
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
|
||||||
input, this->mutable_file_name()));
|
input, this->mutable_file_name()));
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->file_name().data(), this->file_name().length(),
|
this->file_name().data(), static_cast<int>(this->file_name().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::PARSE,
|
::google::protobuf::internal::WireFormatLite::PARSE,
|
||||||
"google.protobuf.SourceContext.file_name"));
|
"google.protobuf.SourceContext.file_name"));
|
||||||
} else {
|
} else {
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
}
|
}
|
||||||
if (input->ExpectAtEnd()) goto success;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if (tag == 0 ||
|
if (tag == 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
|
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||||
|
input, tag, _internal_metadata_.mutable_unknown_fields()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,16 +242,23 @@ failure:
|
|||||||
void SourceContext::SerializeWithCachedSizes(
|
void SourceContext::SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
::google::protobuf::io::CodedOutputStream* output) const {
|
||||||
// @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext)
|
||||||
// optional string file_name = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// string file_name = 1;
|
||||||
if (this->file_name().size() > 0) {
|
if (this->file_name().size() > 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->file_name().data(), this->file_name().length(),
|
this->file_name().data(), static_cast<int>(this->file_name().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.SourceContext.file_name");
|
"google.protobuf.SourceContext.file_name");
|
||||||
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
|
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
|
||||||
1, this->file_name(), output);
|
1, this->file_name(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_end:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(serialize_end:google.protobuf.SourceContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,10 +266,13 @@ void SourceContext::SerializeWithCachedSizes(
|
|||||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||||
(void)deterministic; // Unused
|
(void)deterministic; // Unused
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)
|
||||||
// optional string file_name = 1;
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// string file_name = 1;
|
||||||
if (this->file_name().size() > 0) {
|
if (this->file_name().size() > 0) {
|
||||||
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->file_name().data(), this->file_name().length(),
|
this->file_name().data(), static_cast<int>(this->file_name().length()),
|
||||||
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
::google::protobuf::internal::WireFormatLite::SERIALIZE,
|
||||||
"google.protobuf.SourceContext.file_name");
|
"google.protobuf.SourceContext.file_name");
|
||||||
target =
|
target =
|
||||||
@@ -270,6 +280,10 @@ void SourceContext::SerializeWithCachedSizes(
|
|||||||
1, this->file_name(), target);
|
1, this->file_name(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
|
||||||
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -278,7 +292,12 @@ size_t SourceContext::ByteSizeLong() const {
|
|||||||
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
// optional string file_name = 1;
|
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
|
||||||
|
total_size +=
|
||||||
|
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||||
|
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
|
||||||
|
}
|
||||||
|
// string file_name = 1;
|
||||||
if (this->file_name().size() > 0) {
|
if (this->file_name().size() > 0) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::google::protobuf::internal::WireFormatLite::StringSize(
|
::google::protobuf::internal::WireFormatLite::StringSize(
|
||||||
@@ -294,7 +313,7 @@ size_t SourceContext::ByteSizeLong() const {
|
|||||||
|
|
||||||
void SourceContext::MergeFrom(const ::google::protobuf::Message& from) {
|
void SourceContext::MergeFrom(const ::google::protobuf::Message& from) {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext)
|
||||||
if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
const SourceContext* source =
|
const SourceContext* source =
|
||||||
::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>(
|
::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>(
|
||||||
&from);
|
&from);
|
||||||
@@ -303,21 +322,17 @@ void SourceContext::MergeFrom(const ::google::protobuf::Message& from) {
|
|||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||||
} else {
|
} else {
|
||||||
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext)
|
||||||
UnsafeMergeFrom(*source);
|
MergeFrom(*source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceContext::MergeFrom(const SourceContext& from) {
|
void SourceContext::MergeFrom(const SourceContext& from) {
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext)
|
||||||
if (GOOGLE_PREDICT_TRUE(&from != this)) {
|
GOOGLE_DCHECK_NE(&from, this);
|
||||||
UnsafeMergeFrom(from);
|
_internal_metadata_.MergeFrom(from._internal_metadata_);
|
||||||
} else {
|
::google::protobuf::uint32 cached_has_bits = 0;
|
||||||
MergeFromFail(__LINE__);
|
(void) cached_has_bits;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SourceContext::UnsafeMergeFrom(const SourceContext& from) {
|
|
||||||
GOOGLE_DCHECK(&from != this);
|
|
||||||
if (from.file_name().size() > 0) {
|
if (from.file_name().size() > 0) {
|
||||||
|
|
||||||
file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
|
file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
|
||||||
@@ -335,11 +350,10 @@ void SourceContext::CopyFrom(const SourceContext& from) {
|
|||||||
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext)
|
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
UnsafeMergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourceContext::IsInitialized() const {
|
bool SourceContext::IsInitialized() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,73 +362,19 @@ void SourceContext::Swap(SourceContext* other) {
|
|||||||
InternalSwap(other);
|
InternalSwap(other);
|
||||||
}
|
}
|
||||||
void SourceContext::InternalSwap(SourceContext* other) {
|
void SourceContext::InternalSwap(SourceContext* other) {
|
||||||
|
using std::swap;
|
||||||
file_name_.Swap(&other->file_name_);
|
file_name_.Swap(&other->file_name_);
|
||||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
swap(_cached_size_, other->_cached_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
::google::protobuf::Metadata SourceContext::GetMetadata() const {
|
::google::protobuf::Metadata SourceContext::GetMetadata() const {
|
||||||
protobuf_AssignDescriptorsOnce();
|
protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
|
||||||
::google::protobuf::Metadata metadata;
|
return ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[kIndexInFileMessages];
|
||||||
metadata.descriptor = SourceContext_descriptor_;
|
|
||||||
metadata.reflection = SourceContext_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
// SourceContext
|
|
||||||
|
|
||||||
// optional string file_name = 1;
|
|
||||||
void SourceContext::clear_file_name() {
|
|
||||||
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
const ::std::string& SourceContext::file_name() const {
|
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
|
|
||||||
return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void SourceContext::set_file_name(const ::std::string& value) {
|
|
||||||
|
|
||||||
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
|
|
||||||
}
|
|
||||||
void SourceContext::set_file_name(const char* value) {
|
|
||||||
|
|
||||||
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)
|
|
||||||
}
|
|
||||||
void SourceContext::set_file_name(const char* value, size_t size) {
|
|
||||||
|
|
||||||
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
|
|
||||||
::std::string(reinterpret_cast<const char*>(value), size));
|
|
||||||
// @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name)
|
|
||||||
}
|
|
||||||
::std::string* SourceContext::mutable_file_name() {
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name)
|
|
||||||
return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
::std::string* SourceContext::release_file_name() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)
|
|
||||||
|
|
||||||
return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
|
||||||
}
|
|
||||||
void SourceContext::set_allocated_file_name(::std::string* file_name) {
|
|
||||||
if (file_name != NULL) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const SourceContext* SourceContext::internal_default_instance() {
|
|
||||||
return &SourceContext_default_instance_.get();
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
|||||||
+92
-47
@@ -8,37 +8,55 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[1];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsSourceContextImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsSourceContext();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsSourceContext();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
|
|
||||||
class SourceContext;
|
class SourceContext;
|
||||||
|
class SourceContextDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@@ -53,63 +71,85 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
SourceContext(SourceContext&& from) noexcept
|
||||||
|
: SourceContext() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SourceContext& operator=(SourceContext&& from) noexcept {
|
||||||
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const SourceContext& default_instance();
|
static const SourceContext& default_instance();
|
||||||
|
|
||||||
static const SourceContext* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const SourceContext* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const SourceContext*>(
|
||||||
|
&_SourceContext_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
0;
|
||||||
|
|
||||||
void Swap(SourceContext* other);
|
void Swap(SourceContext* other);
|
||||||
|
friend void swap(SourceContext& a, SourceContext& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline SourceContext* New() const { return New(NULL); }
|
inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
SourceContext* New(::google::protobuf::Arena* arena) const;
|
SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const SourceContext& from);
|
void CopyFrom(const SourceContext& from);
|
||||||
void MergeFrom(const SourceContext& from);
|
void MergeFrom(const SourceContext& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(SourceContext* other);
|
void InternalSwap(SourceContext* other);
|
||||||
void UnsafeMergeFrom(const SourceContext& from);
|
|
||||||
private:
|
private:
|
||||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
|
||||||
return _internal_metadata_.arena();
|
return NULL;
|
||||||
}
|
}
|
||||||
inline void* MaybeArenaPtr() const {
|
inline void* MaybeArenaPtr() const {
|
||||||
return _internal_metadata_.raw_arena_ptr();
|
return NULL;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional string file_name = 1;
|
// string file_name = 1;
|
||||||
void clear_file_name();
|
void clear_file_name();
|
||||||
static const int kFileNameFieldNumber = 1;
|
static const int kFileNameFieldNumber = 1;
|
||||||
const ::std::string& file_name() const;
|
const ::std::string& file_name() const;
|
||||||
void set_file_name(const ::std::string& value);
|
void set_file_name(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_file_name(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_file_name(const char* value);
|
void set_file_name(const char* value);
|
||||||
void set_file_name(const char* value, size_t size);
|
void set_file_name(const char* value, size_t size);
|
||||||
::std::string* mutable_file_name();
|
::std::string* mutable_file_name();
|
||||||
@@ -122,37 +162,43 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
|
|||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
::google::protobuf::internal::ArenaStringPtr file_name_;
|
::google::protobuf::internal::ArenaStringPtr file_name_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaultsSourceContextImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
// SourceContext
|
// SourceContext
|
||||||
|
|
||||||
// optional string file_name = 1;
|
// string file_name = 1;
|
||||||
inline void SourceContext::clear_file_name() {
|
inline void SourceContext::clear_file_name() {
|
||||||
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
inline const ::std::string& SourceContext::file_name() const {
|
inline const ::std::string& SourceContext::file_name() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
|
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
|
||||||
return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return file_name_.GetNoArena();
|
||||||
}
|
}
|
||||||
inline void SourceContext::set_file_name(const ::std::string& value) {
|
inline void SourceContext::set_file_name(const ::std::string& value) {
|
||||||
|
|
||||||
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
|
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void SourceContext::set_file_name(::std::string&& value) {
|
||||||
|
|
||||||
|
file_name_.SetNoArena(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void SourceContext::set_file_name(const char* value) {
|
inline void SourceContext::set_file_name(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
|
|
||||||
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||||
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)
|
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)
|
||||||
@@ -183,10 +229,9 @@ inline void SourceContext::set_allocated_file_name(::std::string* file_name) {
|
|||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const SourceContext* SourceContext::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &SourceContext_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
// @@protoc_insertion_point(namespace_scope)
|
||||||
|
|
||||||
|
|||||||
+505
-869
File diff suppressed because it is too large
Load Diff
+332
-273
@@ -8,42 +8,68 @@
|
|||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
#if GOOGLE_PROTOBUF_VERSION < 3005000
|
||||||
#error This file was generated by a newer version of protoc which is
|
#error This file was generated by a newer version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
#error incompatible with your Protocol Buffer headers. Please update
|
||||||
#error your headers.
|
#error your headers.
|
||||||
#endif
|
#endif
|
||||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||||
#error This file was generated by an older version of protoc which is
|
#error This file was generated by an older version of protoc which is
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
#error incompatible with your Protocol Buffer headers. Please
|
||||||
#error regenerate this file with a newer version of protoc.
|
#error regenerate this file with a newer version of protoc.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include <google/protobuf/arena.h>
|
#include <google/protobuf/arena.h>
|
||||||
#include <google/protobuf/arenastring.h>
|
#include <google/protobuf/arenastring.h>
|
||||||
|
#include <google/protobuf/generated_message_table_driven.h>
|
||||||
#include <google/protobuf/generated_message_util.h>
|
#include <google/protobuf/generated_message_util.h>
|
||||||
#include <google/protobuf/metadata.h>
|
#include <google/protobuf/metadata.h>
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/repeated_field.h>
|
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/extension_set.h>
|
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
||||||
#include <google/protobuf/map.h>
|
#include <google/protobuf/map.h> // IWYU pragma: export
|
||||||
|
#include <google/protobuf/map_entry.h>
|
||||||
#include <google/protobuf/map_field_inl.h>
|
#include <google/protobuf/map_field_inl.h>
|
||||||
#include <google/protobuf/generated_enum_reflection.h>
|
#include <google/protobuf/generated_enum_reflection.h>
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
#include <google/protobuf/unknown_field_set.h>
|
||||||
// @@protoc_insertion_point(includes)
|
// @@protoc_insertion_point(includes)
|
||||||
|
|
||||||
|
namespace protobuf_google_2fprotobuf_2fstruct_2eproto {
|
||||||
|
// Internal implementation detail -- do not use these members.
|
||||||
|
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||||
|
static const ::google::protobuf::internal::ParseTableField entries[];
|
||||||
|
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
|
||||||
|
static const ::google::protobuf::internal::ParseTable schema[4];
|
||||||
|
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
|
||||||
|
static const ::google::protobuf::internal::SerializationTable serialization_table[];
|
||||||
|
static const ::google::protobuf::uint32 offsets[];
|
||||||
|
};
|
||||||
|
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsListValueImpl();
|
||||||
|
void LIBPROTOBUF_EXPORT InitDefaultsListValue();
|
||||||
|
inline void LIBPROTOBUF_EXPORT InitDefaults() {
|
||||||
|
InitDefaultsListValue();
|
||||||
|
}
|
||||||
|
} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
|
|
||||||
class ListValue;
|
class ListValue;
|
||||||
|
class ListValueDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_;
|
||||||
class Struct;
|
class Struct;
|
||||||
|
class StructDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_;
|
||||||
|
class Struct_FieldsEntry_DoNotUse;
|
||||||
|
class Struct_FieldsEntry_DoNotUseDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
|
||||||
class Value;
|
class Value;
|
||||||
|
class ValueDefaultTypeInternal;
|
||||||
|
LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
|
||||||
|
} // namespace protobuf
|
||||||
|
} // namespace google
|
||||||
|
namespace google {
|
||||||
|
namespace protobuf {
|
||||||
|
|
||||||
enum NullValue {
|
enum NullValue {
|
||||||
NULL_VALUE = 0,
|
NULL_VALUE = 0,
|
||||||
@@ -67,6 +93,27 @@ inline bool NullValue_Parse(
|
|||||||
}
|
}
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
class Struct_FieldsEntry_DoNotUse : public ::google::protobuf::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
|
||||||
|
::std::string, ::google::protobuf::Value,
|
||||||
|
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
|
||||||
|
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
|
||||||
|
0 > {
|
||||||
|
public:
|
||||||
|
typedef ::google::protobuf::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
|
||||||
|
::std::string, ::google::protobuf::Value,
|
||||||
|
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
|
||||||
|
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
|
||||||
|
0 > SuperType;
|
||||||
|
Struct_FieldsEntry_DoNotUse();
|
||||||
|
Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* arena);
|
||||||
|
void MergeFrom(const Struct_FieldsEntry_DoNotUse& other);
|
||||||
|
static const Struct_FieldsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const Struct_FieldsEntry_DoNotUse*>(&_Struct_FieldsEntry_DoNotUse_default_instance_); }
|
||||||
|
void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL;
|
||||||
|
::google::protobuf::Metadata GetMetadata() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
|
class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
|
||||||
public:
|
public:
|
||||||
Struct();
|
Struct();
|
||||||
@@ -78,48 +125,69 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Struct(Struct&& from) noexcept
|
||||||
|
: Struct() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
|
inline Struct& operator=(Struct&& from) noexcept {
|
||||||
inline void* GetMaybeArenaPointer() const {
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
|
||||||
|
return GetArenaNoVirtual();
|
||||||
|
}
|
||||||
|
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
|
||||||
return MaybeArenaPtr();
|
return MaybeArenaPtr();
|
||||||
}
|
}
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const Struct& default_instance();
|
static const Struct& default_instance();
|
||||||
|
|
||||||
static const Struct* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Struct* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Struct*>(
|
||||||
|
&_Struct_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
1;
|
||||||
|
|
||||||
void UnsafeArenaSwap(Struct* other);
|
void UnsafeArenaSwap(Struct* other);
|
||||||
void Swap(Struct* other);
|
void Swap(Struct* other);
|
||||||
|
friend void swap(Struct& a, Struct& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Struct* New() const { return New(NULL); }
|
inline Struct* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Struct* New(::google::protobuf::Arena* arena) const;
|
Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Struct& from);
|
void CopyFrom(const Struct& from);
|
||||||
void MergeFrom(const Struct& from);
|
void MergeFrom(const Struct& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Struct* other);
|
void InternalSwap(Struct* other);
|
||||||
void UnsafeMergeFrom(const Struct& from);
|
|
||||||
protected:
|
protected:
|
||||||
explicit Struct(::google::protobuf::Arena* arena);
|
explicit Struct(::google::protobuf::Arena* arena);
|
||||||
private:
|
private:
|
||||||
@@ -134,7 +202,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
@@ -154,30 +222,19 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
friend class ::google::protobuf::Arena;
|
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
typedef ::google::protobuf::internal::MapEntryLite<
|
|
||||||
::std::string, ::google::protobuf::Value,
|
|
||||||
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
|
|
||||||
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
|
|
||||||
0 >
|
|
||||||
Struct_FieldsEntry;
|
|
||||||
::google::protobuf::internal::MapField<
|
::google::protobuf::internal::MapField<
|
||||||
|
Struct_FieldsEntry_DoNotUse,
|
||||||
::std::string, ::google::protobuf::Value,
|
::std::string, ::google::protobuf::Value,
|
||||||
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
|
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
|
||||||
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
|
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
|
||||||
0 > fields_;
|
0 > fields_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
|
class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
|
||||||
@@ -191,9 +248,25 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
Value(Value&& from) noexcept
|
||||||
|
: Value() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
|
inline Value& operator=(Value&& from) noexcept {
|
||||||
inline void* GetMaybeArenaPointer() const {
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
|
||||||
|
return GetArenaNoVirtual();
|
||||||
|
}
|
||||||
|
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
|
||||||
return MaybeArenaPtr();
|
return MaybeArenaPtr();
|
||||||
}
|
}
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
@@ -209,40 +282,45 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
KIND_NOT_SET = 0,
|
KIND_NOT_SET = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Value* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const Value* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const Value*>(
|
||||||
|
&_Value_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
2;
|
||||||
|
|
||||||
void UnsafeArenaSwap(Value* other);
|
void UnsafeArenaSwap(Value* other);
|
||||||
void Swap(Value* other);
|
void Swap(Value* other);
|
||||||
|
friend void swap(Value& a, Value& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline Value* New() const { return New(NULL); }
|
inline Value* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
Value* New(::google::protobuf::Arena* arena) const;
|
Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const Value& from);
|
void CopyFrom(const Value& from);
|
||||||
void MergeFrom(const Value& from);
|
void MergeFrom(const Value& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(Value* other);
|
void InternalSwap(Value* other);
|
||||||
void UnsafeMergeFrom(const Value& from);
|
|
||||||
protected:
|
protected:
|
||||||
explicit Value(::google::protobuf::Arena* arena);
|
explicit Value(::google::protobuf::Arena* arena);
|
||||||
private:
|
private:
|
||||||
@@ -257,13 +335,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
// optional .google.protobuf.NullValue null_value = 1;
|
// .google.protobuf.NullValue null_value = 1;
|
||||||
private:
|
private:
|
||||||
bool has_null_value() const;
|
bool has_null_value() const;
|
||||||
public:
|
public:
|
||||||
@@ -272,7 +350,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
::google::protobuf::NullValue null_value() const;
|
::google::protobuf::NullValue null_value() const;
|
||||||
void set_null_value(::google::protobuf::NullValue value);
|
void set_null_value(::google::protobuf::NullValue value);
|
||||||
|
|
||||||
// optional double number_value = 2;
|
// double number_value = 2;
|
||||||
private:
|
private:
|
||||||
bool has_number_value() const;
|
bool has_number_value() const;
|
||||||
public:
|
public:
|
||||||
@@ -281,7 +359,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
double number_value() const;
|
double number_value() const;
|
||||||
void set_number_value(double value);
|
void set_number_value(double value);
|
||||||
|
|
||||||
// optional string string_value = 3;
|
// string string_value = 3;
|
||||||
private:
|
private:
|
||||||
bool has_string_value() const;
|
bool has_string_value() const;
|
||||||
public:
|
public:
|
||||||
@@ -289,16 +367,25 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
static const int kStringValueFieldNumber = 3;
|
static const int kStringValueFieldNumber = 3;
|
||||||
const ::std::string& string_value() const;
|
const ::std::string& string_value() const;
|
||||||
void set_string_value(const ::std::string& value);
|
void set_string_value(const ::std::string& value);
|
||||||
|
#if LANG_CXX11
|
||||||
|
void set_string_value(::std::string&& value);
|
||||||
|
#endif
|
||||||
void set_string_value(const char* value);
|
void set_string_value(const char* value);
|
||||||
void set_string_value(const char* value, size_t size);
|
void set_string_value(const char* value, size_t size);
|
||||||
::std::string* mutable_string_value();
|
::std::string* mutable_string_value();
|
||||||
::std::string* release_string_value();
|
::std::string* release_string_value();
|
||||||
void set_allocated_string_value(::std::string* string_value);
|
void set_allocated_string_value(::std::string* string_value);
|
||||||
|
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
|
||||||
|
" string fields are deprecated and will be removed in a"
|
||||||
|
" future release.")
|
||||||
::std::string* unsafe_arena_release_string_value();
|
::std::string* unsafe_arena_release_string_value();
|
||||||
|
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
|
||||||
|
" string fields are deprecated and will be removed in a"
|
||||||
|
" future release.")
|
||||||
void unsafe_arena_set_allocated_string_value(
|
void unsafe_arena_set_allocated_string_value(
|
||||||
::std::string* string_value);
|
::std::string* string_value);
|
||||||
|
|
||||||
// optional bool bool_value = 4;
|
// bool bool_value = 4;
|
||||||
private:
|
private:
|
||||||
bool has_bool_value() const;
|
bool has_bool_value() const;
|
||||||
public:
|
public:
|
||||||
@@ -307,58 +394,52 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
bool bool_value() const;
|
bool bool_value() const;
|
||||||
void set_bool_value(bool value);
|
void set_bool_value(bool value);
|
||||||
|
|
||||||
// optional .google.protobuf.Struct struct_value = 5;
|
// .google.protobuf.Struct struct_value = 5;
|
||||||
bool has_struct_value() const;
|
bool has_struct_value() const;
|
||||||
void clear_struct_value();
|
void clear_struct_value();
|
||||||
static const int kStructValueFieldNumber = 5;
|
static const int kStructValueFieldNumber = 5;
|
||||||
private:
|
private:
|
||||||
void _slow_mutable_struct_value();
|
void _slow_mutable_struct_value();
|
||||||
void _slow_set_allocated_struct_value(
|
|
||||||
::google::protobuf::Arena* message_arena, ::google::protobuf::Struct** struct_value);
|
|
||||||
::google::protobuf::Struct* _slow_release_struct_value();
|
|
||||||
public:
|
public:
|
||||||
const ::google::protobuf::Struct& struct_value() const;
|
const ::google::protobuf::Struct& struct_value() const;
|
||||||
::google::protobuf::Struct* mutable_struct_value();
|
|
||||||
::google::protobuf::Struct* release_struct_value();
|
::google::protobuf::Struct* release_struct_value();
|
||||||
|
::google::protobuf::Struct* mutable_struct_value();
|
||||||
void set_allocated_struct_value(::google::protobuf::Struct* struct_value);
|
void set_allocated_struct_value(::google::protobuf::Struct* struct_value);
|
||||||
::google::protobuf::Struct* unsafe_arena_release_struct_value();
|
|
||||||
void unsafe_arena_set_allocated_struct_value(
|
void unsafe_arena_set_allocated_struct_value(
|
||||||
::google::protobuf::Struct* struct_value);
|
::google::protobuf::Struct* struct_value);
|
||||||
|
::google::protobuf::Struct* unsafe_arena_release_struct_value();
|
||||||
|
|
||||||
// optional .google.protobuf.ListValue list_value = 6;
|
// .google.protobuf.ListValue list_value = 6;
|
||||||
bool has_list_value() const;
|
bool has_list_value() const;
|
||||||
void clear_list_value();
|
void clear_list_value();
|
||||||
static const int kListValueFieldNumber = 6;
|
static const int kListValueFieldNumber = 6;
|
||||||
private:
|
private:
|
||||||
void _slow_mutable_list_value();
|
void _slow_mutable_list_value();
|
||||||
void _slow_set_allocated_list_value(
|
|
||||||
::google::protobuf::Arena* message_arena, ::google::protobuf::ListValue** list_value);
|
|
||||||
::google::protobuf::ListValue* _slow_release_list_value();
|
|
||||||
public:
|
public:
|
||||||
const ::google::protobuf::ListValue& list_value() const;
|
const ::google::protobuf::ListValue& list_value() const;
|
||||||
::google::protobuf::ListValue* mutable_list_value();
|
|
||||||
::google::protobuf::ListValue* release_list_value();
|
::google::protobuf::ListValue* release_list_value();
|
||||||
|
::google::protobuf::ListValue* mutable_list_value();
|
||||||
void set_allocated_list_value(::google::protobuf::ListValue* list_value);
|
void set_allocated_list_value(::google::protobuf::ListValue* list_value);
|
||||||
::google::protobuf::ListValue* unsafe_arena_release_list_value();
|
|
||||||
void unsafe_arena_set_allocated_list_value(
|
void unsafe_arena_set_allocated_list_value(
|
||||||
::google::protobuf::ListValue* list_value);
|
::google::protobuf::ListValue* list_value);
|
||||||
|
::google::protobuf::ListValue* unsafe_arena_release_list_value();
|
||||||
|
|
||||||
KindCase kind_case() const;
|
KindCase kind_case() const;
|
||||||
// @@protoc_insertion_point(class_scope:google.protobuf.Value)
|
// @@protoc_insertion_point(class_scope:google.protobuf.Value)
|
||||||
private:
|
private:
|
||||||
inline void set_has_null_value();
|
void set_has_null_value();
|
||||||
inline void set_has_number_value();
|
void set_has_number_value();
|
||||||
inline void set_has_string_value();
|
void set_has_string_value();
|
||||||
inline void set_has_bool_value();
|
void set_has_bool_value();
|
||||||
inline void set_has_struct_value();
|
void set_has_struct_value();
|
||||||
inline void set_has_list_value();
|
void set_has_list_value();
|
||||||
|
|
||||||
inline bool has_kind() const;
|
inline bool has_kind() const;
|
||||||
void clear_kind();
|
void clear_kind();
|
||||||
inline void clear_has_kind();
|
inline void clear_has_kind();
|
||||||
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
friend class ::google::protobuf::Arena;
|
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
union KindUnion {
|
union KindUnion {
|
||||||
@@ -373,15 +454,9 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
|
|||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
::google::protobuf::uint32 _oneof_case_[1];
|
::google::protobuf::uint32 _oneof_case_[1];
|
||||||
|
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
|
class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
|
||||||
@@ -395,48 +470,69 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
|
|||||||
CopyFrom(from);
|
CopyFrom(from);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
ListValue(ListValue&& from) noexcept
|
||||||
|
: ListValue() {
|
||||||
|
*this = ::std::move(from);
|
||||||
|
}
|
||||||
|
|
||||||
inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
|
inline ListValue& operator=(ListValue&& from) noexcept {
|
||||||
inline void* GetMaybeArenaPointer() const {
|
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
|
||||||
|
if (this != &from) InternalSwap(&from);
|
||||||
|
} else {
|
||||||
|
CopyFrom(from);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
|
||||||
|
return GetArenaNoVirtual();
|
||||||
|
}
|
||||||
|
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
|
||||||
return MaybeArenaPtr();
|
return MaybeArenaPtr();
|
||||||
}
|
}
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
static const ::google::protobuf::Descriptor* descriptor();
|
||||||
static const ListValue& default_instance();
|
static const ListValue& default_instance();
|
||||||
|
|
||||||
static const ListValue* internal_default_instance();
|
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
|
||||||
|
static inline const ListValue* internal_default_instance() {
|
||||||
|
return reinterpret_cast<const ListValue*>(
|
||||||
|
&_ListValue_default_instance_);
|
||||||
|
}
|
||||||
|
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
|
||||||
|
3;
|
||||||
|
|
||||||
void UnsafeArenaSwap(ListValue* other);
|
void UnsafeArenaSwap(ListValue* other);
|
||||||
void Swap(ListValue* other);
|
void Swap(ListValue* other);
|
||||||
|
friend void swap(ListValue& a, ListValue& b) {
|
||||||
|
a.Swap(&b);
|
||||||
|
}
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
// implements Message ----------------------------------------------
|
||||||
|
|
||||||
inline ListValue* New() const { return New(NULL); }
|
inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); }
|
||||||
|
|
||||||
ListValue* New(::google::protobuf::Arena* arena) const;
|
ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
|
||||||
void CopyFrom(const ListValue& from);
|
void CopyFrom(const ListValue& from);
|
||||||
void MergeFrom(const ListValue& from);
|
void MergeFrom(const ListValue& from);
|
||||||
void Clear();
|
void Clear() PROTOBUF_FINAL;
|
||||||
bool IsInitialized() const;
|
bool IsInitialized() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
size_t ByteSizeLong() const;
|
size_t ByteSizeLong() const PROTOBUF_FINAL;
|
||||||
bool MergePartialFromCodedStream(
|
bool MergePartialFromCodedStream(
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
|
||||||
void SerializeWithCachedSizes(
|
void SerializeWithCachedSizes(
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
|
||||||
bool deterministic, ::google::protobuf::uint8* output) const;
|
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
|
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
|
||||||
}
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
private:
|
||||||
void SharedCtor();
|
void SharedCtor();
|
||||||
void SharedDtor();
|
void SharedDtor();
|
||||||
void SetCachedSize(int size) const;
|
void SetCachedSize(int size) const PROTOBUF_FINAL;
|
||||||
void InternalSwap(ListValue* other);
|
void InternalSwap(ListValue* other);
|
||||||
void UnsafeMergeFrom(const ListValue& from);
|
|
||||||
protected:
|
protected:
|
||||||
explicit ListValue(::google::protobuf::Arena* arena);
|
explicit ListValue(::google::protobuf::Arena* arena);
|
||||||
private:
|
private:
|
||||||
@@ -451,7 +547,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
@@ -473,26 +569,25 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||||
friend class ::google::protobuf::Arena;
|
template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
|
||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_;
|
::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_;
|
||||||
mutable int _cached_size_;
|
mutable int _cached_size_;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend struct ::protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
|
||||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
|
friend void ::protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaultsListValueImpl();
|
||||||
friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
};
|
};
|
||||||
extern ::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_;
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#endif // __GNUC__
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// Struct
|
// Struct
|
||||||
|
|
||||||
// map<string, .google.protobuf.Value> fields = 1;
|
// map<string, .google.protobuf.Value> fields = 1;
|
||||||
@@ -513,14 +608,11 @@ Struct::mutable_fields() {
|
|||||||
return fields_.MutableMap();
|
return fields_.MutableMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Struct* Struct::internal_default_instance() {
|
|
||||||
return &Struct_default_instance_.get();
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
|
|
||||||
// optional .google.protobuf.NullValue null_value = 1;
|
// .google.protobuf.NullValue null_value = 1;
|
||||||
inline bool Value::has_null_value() const {
|
inline bool Value::has_null_value() const {
|
||||||
return kind_case() == kNullValue;
|
return kind_case() == kNullValue;
|
||||||
}
|
}
|
||||||
@@ -549,7 +641,7 @@ inline void Value::set_null_value(::google::protobuf::NullValue value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
|
// @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional double number_value = 2;
|
// double number_value = 2;
|
||||||
inline bool Value::has_number_value() const {
|
inline bool Value::has_number_value() const {
|
||||||
return kind_case() == kNumberValue;
|
return kind_case() == kNumberValue;
|
||||||
}
|
}
|
||||||
@@ -578,7 +670,7 @@ inline void Value::set_number_value(double value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
|
// @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional string string_value = 3;
|
// string string_value = 3;
|
||||||
inline bool Value::has_string_value() const {
|
inline bool Value::has_string_value() const {
|
||||||
return kind_case() == kStringValue;
|
return kind_case() == kStringValue;
|
||||||
}
|
}
|
||||||
@@ -595,7 +687,7 @@ inline void Value::clear_string_value() {
|
|||||||
inline const ::std::string& Value::string_value() const {
|
inline const ::std::string& Value::string_value() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
|
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
|
||||||
if (has_string_value()) {
|
if (has_string_value()) {
|
||||||
return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
return kind_.string_value_.Get();
|
||||||
}
|
}
|
||||||
return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();
|
return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();
|
||||||
}
|
}
|
||||||
@@ -609,7 +701,21 @@ inline void Value::set_string_value(const ::std::string& value) {
|
|||||||
GetArenaNoVirtual());
|
GetArenaNoVirtual());
|
||||||
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
|
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
|
||||||
}
|
}
|
||||||
|
#if LANG_CXX11
|
||||||
|
inline void Value::set_string_value(::std::string&& value) {
|
||||||
|
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
|
||||||
|
if (!has_string_value()) {
|
||||||
|
clear_kind();
|
||||||
|
set_has_string_value();
|
||||||
|
kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
|
}
|
||||||
|
kind_.string_value_.Set(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArenaNoVirtual());
|
||||||
|
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Value.string_value)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
inline void Value::set_string_value(const char* value) {
|
inline void Value::set_string_value(const char* value) {
|
||||||
|
GOOGLE_DCHECK(value != NULL);
|
||||||
if (!has_string_value()) {
|
if (!has_string_value()) {
|
||||||
clear_kind();
|
clear_kind();
|
||||||
set_has_string_value();
|
set_has_string_value();
|
||||||
@@ -626,7 +732,8 @@ inline void Value::set_string_value(const char* value,
|
|||||||
set_has_string_value();
|
set_has_string_value();
|
||||||
kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
}
|
}
|
||||||
kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(
|
kind_.string_value_.Set(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(
|
||||||
reinterpret_cast<const char*>(value), size),
|
reinterpret_cast<const char*>(value), size),
|
||||||
GetArenaNoVirtual());
|
GetArenaNoVirtual());
|
||||||
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value)
|
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value)
|
||||||
@@ -651,17 +758,6 @@ inline ::std::string* Value::release_string_value() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline ::std::string* Value::unsafe_arena_release_string_value() {
|
|
||||||
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value)
|
|
||||||
GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
|
|
||||||
if (has_string_value()) {
|
|
||||||
clear_has_kind();
|
|
||||||
return kind_.string_value_.UnsafeArenaRelease(
|
|
||||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Value::set_allocated_string_value(::std::string* string_value) {
|
inline void Value::set_allocated_string_value(::std::string* string_value) {
|
||||||
if (!has_string_value()) {
|
if (!has_string_value()) {
|
||||||
kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||||
@@ -674,6 +770,17 @@ inline void Value::set_allocated_string_value(::std::string* string_value) {
|
|||||||
}
|
}
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
|
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
|
||||||
}
|
}
|
||||||
|
inline ::std::string* Value::unsafe_arena_release_string_value() {
|
||||||
|
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value)
|
||||||
|
GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
|
||||||
|
if (has_string_value()) {
|
||||||
|
clear_has_kind();
|
||||||
|
return kind_.string_value_.UnsafeArenaRelease(
|
||||||
|
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) {
|
inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) {
|
||||||
GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
|
GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);
|
||||||
if (!has_string_value()) {
|
if (!has_string_value()) {
|
||||||
@@ -687,7 +794,7 @@ inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string
|
|||||||
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value)
|
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional bool bool_value = 4;
|
// bool bool_value = 4;
|
||||||
inline bool Value::has_bool_value() const {
|
inline bool Value::has_bool_value() const {
|
||||||
return kind_case() == kBoolValue;
|
return kind_case() == kBoolValue;
|
||||||
}
|
}
|
||||||
@@ -716,7 +823,7 @@ inline void Value::set_bool_value(bool value) {
|
|||||||
// @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
|
// @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional .google.protobuf.Struct struct_value = 5;
|
// .google.protobuf.Struct struct_value = 5;
|
||||||
inline bool Value::has_struct_value() const {
|
inline bool Value::has_struct_value() const {
|
||||||
return kind_case() == kStructValue;
|
return kind_case() == kStructValue;
|
||||||
}
|
}
|
||||||
@@ -731,11 +838,44 @@ inline void Value::clear_struct_value() {
|
|||||||
clear_has_kind();
|
clear_has_kind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline const ::google::protobuf::Struct& Value::struct_value() const {
|
inline ::google::protobuf::Struct* Value::release_struct_value() {
|
||||||
|
// @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)
|
||||||
|
if (has_struct_value()) {
|
||||||
|
clear_has_kind();
|
||||||
|
::google::protobuf::Struct* temp = kind_.struct_value_;
|
||||||
|
if (GetArenaNoVirtual() != NULL) {
|
||||||
|
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);
|
||||||
|
}
|
||||||
|
kind_.struct_value_ = NULL;
|
||||||
|
return temp;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline const ::google::protobuf::Struct& Value::struct_value() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value)
|
// @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value)
|
||||||
return has_struct_value()
|
return has_struct_value()
|
||||||
? *kind_.struct_value_
|
? *kind_.struct_value_
|
||||||
: ::google::protobuf::Struct::default_instance();
|
: *reinterpret_cast< ::google::protobuf::Struct*>(&::google::protobuf::_Struct_default_instance_);
|
||||||
|
}
|
||||||
|
inline ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() {
|
||||||
|
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value)
|
||||||
|
if (has_struct_value()) {
|
||||||
|
clear_has_kind();
|
||||||
|
::google::protobuf::Struct* temp = kind_.struct_value_;
|
||||||
|
kind_.struct_value_ = NULL;
|
||||||
|
return temp;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::Struct* struct_value) {
|
||||||
|
clear_kind();
|
||||||
|
if (struct_value) {
|
||||||
|
set_has_struct_value();
|
||||||
|
kind_.struct_value_ = struct_value;
|
||||||
|
}
|
||||||
|
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::Struct* Value::mutable_struct_value() {
|
inline ::google::protobuf::Struct* Value::mutable_struct_value() {
|
||||||
if (!has_struct_value()) {
|
if (!has_struct_value()) {
|
||||||
@@ -748,63 +888,8 @@ inline ::google::protobuf::Struct* Value::mutable_struct_value() {
|
|||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)
|
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)
|
||||||
return kind_.struct_value_;
|
return kind_.struct_value_;
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::Struct* Value::release_struct_value() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)
|
|
||||||
if (has_struct_value()) {
|
|
||||||
clear_has_kind();
|
|
||||||
if (GetArenaNoVirtual() != NULL) {
|
|
||||||
::google::protobuf::Struct* temp = new ::google::protobuf::Struct(*kind_.struct_value_);
|
|
||||||
kind_.struct_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
} else {
|
|
||||||
::google::protobuf::Struct* temp = kind_.struct_value_;
|
|
||||||
kind_.struct_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) {
|
|
||||||
clear_kind();
|
|
||||||
if (struct_value) {
|
|
||||||
if (GetArenaNoVirtual() != NULL &&
|
|
||||||
::google::protobuf::Arena::GetArena(struct_value) == NULL) {
|
|
||||||
GetArenaNoVirtual()->Own(struct_value);
|
|
||||||
} else if (GetArenaNoVirtual() !=
|
|
||||||
::google::protobuf::Arena::GetArena(struct_value)) {
|
|
||||||
::google::protobuf::Struct* new_struct_value =
|
|
||||||
::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >(
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
new_struct_value->CopyFrom(*struct_value);
|
|
||||||
struct_value = new_struct_value;
|
|
||||||
}
|
|
||||||
set_has_struct_value();
|
|
||||||
kind_.struct_value_ = struct_value;
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value)
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() {
|
|
||||||
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value)
|
|
||||||
if (has_struct_value()) {
|
|
||||||
clear_has_kind();
|
|
||||||
::google::protobuf::Struct* temp = kind_.struct_value_;
|
|
||||||
kind_.struct_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::Struct* struct_value) {
|
|
||||||
clear_kind();
|
|
||||||
if (struct_value) {
|
|
||||||
set_has_struct_value();
|
|
||||||
kind_.struct_value_ = struct_value;
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .google.protobuf.ListValue list_value = 6;
|
// .google.protobuf.ListValue list_value = 6;
|
||||||
inline bool Value::has_list_value() const {
|
inline bool Value::has_list_value() const {
|
||||||
return kind_case() == kListValue;
|
return kind_case() == kListValue;
|
||||||
}
|
}
|
||||||
@@ -819,11 +904,44 @@ inline void Value::clear_list_value() {
|
|||||||
clear_has_kind();
|
clear_has_kind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline const ::google::protobuf::ListValue& Value::list_value() const {
|
inline ::google::protobuf::ListValue* Value::release_list_value() {
|
||||||
|
// @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)
|
||||||
|
if (has_list_value()) {
|
||||||
|
clear_has_kind();
|
||||||
|
::google::protobuf::ListValue* temp = kind_.list_value_;
|
||||||
|
if (GetArenaNoVirtual() != NULL) {
|
||||||
|
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp, NULL);
|
||||||
|
}
|
||||||
|
kind_.list_value_ = NULL;
|
||||||
|
return temp;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline const ::google::protobuf::ListValue& Value::list_value() const {
|
||||||
// @@protoc_insertion_point(field_get:google.protobuf.Value.list_value)
|
// @@protoc_insertion_point(field_get:google.protobuf.Value.list_value)
|
||||||
return has_list_value()
|
return has_list_value()
|
||||||
? *kind_.list_value_
|
? *kind_.list_value_
|
||||||
: ::google::protobuf::ListValue::default_instance();
|
: *reinterpret_cast< ::google::protobuf::ListValue*>(&::google::protobuf::_ListValue_default_instance_);
|
||||||
|
}
|
||||||
|
inline ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() {
|
||||||
|
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value)
|
||||||
|
if (has_list_value()) {
|
||||||
|
clear_has_kind();
|
||||||
|
::google::protobuf::ListValue* temp = kind_.list_value_;
|
||||||
|
kind_.list_value_ = NULL;
|
||||||
|
return temp;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::ListValue* list_value) {
|
||||||
|
clear_kind();
|
||||||
|
if (list_value) {
|
||||||
|
set_has_list_value();
|
||||||
|
kind_.list_value_ = list_value;
|
||||||
|
}
|
||||||
|
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value)
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::ListValue* Value::mutable_list_value() {
|
inline ::google::protobuf::ListValue* Value::mutable_list_value() {
|
||||||
if (!has_list_value()) {
|
if (!has_list_value()) {
|
||||||
@@ -836,61 +954,6 @@ inline ::google::protobuf::ListValue* Value::mutable_list_value() {
|
|||||||
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)
|
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)
|
||||||
return kind_.list_value_;
|
return kind_.list_value_;
|
||||||
}
|
}
|
||||||
inline ::google::protobuf::ListValue* Value::release_list_value() {
|
|
||||||
// @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)
|
|
||||||
if (has_list_value()) {
|
|
||||||
clear_has_kind();
|
|
||||||
if (GetArenaNoVirtual() != NULL) {
|
|
||||||
::google::protobuf::ListValue* temp = new ::google::protobuf::ListValue(*kind_.list_value_);
|
|
||||||
kind_.list_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
} else {
|
|
||||||
::google::protobuf::ListValue* temp = kind_.list_value_;
|
|
||||||
kind_.list_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) {
|
|
||||||
clear_kind();
|
|
||||||
if (list_value) {
|
|
||||||
if (GetArenaNoVirtual() != NULL &&
|
|
||||||
::google::protobuf::Arena::GetArena(list_value) == NULL) {
|
|
||||||
GetArenaNoVirtual()->Own(list_value);
|
|
||||||
} else if (GetArenaNoVirtual() !=
|
|
||||||
::google::protobuf::Arena::GetArena(list_value)) {
|
|
||||||
::google::protobuf::ListValue* new_list_value =
|
|
||||||
::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >(
|
|
||||||
GetArenaNoVirtual());
|
|
||||||
new_list_value->CopyFrom(*list_value);
|
|
||||||
list_value = new_list_value;
|
|
||||||
}
|
|
||||||
set_has_list_value();
|
|
||||||
kind_.list_value_ = list_value;
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value)
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() {
|
|
||||||
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value)
|
|
||||||
if (has_list_value()) {
|
|
||||||
clear_has_kind();
|
|
||||||
::google::protobuf::ListValue* temp = kind_.list_value_;
|
|
||||||
kind_.list_value_ = NULL;
|
|
||||||
return temp;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::ListValue* list_value) {
|
|
||||||
clear_kind();
|
|
||||||
if (list_value) {
|
|
||||||
set_has_list_value();
|
|
||||||
kind_.list_value_ = list_value;
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool Value::has_kind() const {
|
inline bool Value::has_kind() const {
|
||||||
return kind_case() != KIND_NOT_SET;
|
return kind_case() != KIND_NOT_SET;
|
||||||
@@ -901,9 +964,6 @@ inline void Value::clear_has_kind() {
|
|||||||
inline Value::KindCase Value::kind_case() const {
|
inline Value::KindCase Value::kind_case() const {
|
||||||
return Value::KindCase(_oneof_case_[0]);
|
return Value::KindCase(_oneof_case_[0]);
|
||||||
}
|
}
|
||||||
inline const Value* Value::internal_default_instance() {
|
|
||||||
return &Value_default_instance_.get();
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// ListValue
|
// ListValue
|
||||||
@@ -938,10 +998,11 @@ ListValue::values() const {
|
|||||||
return values_;
|
return values_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ListValue* ListValue::internal_default_instance() {
|
#ifdef __GNUC__
|
||||||
return &ListValue_default_instance_.get();
|
#pragma GCC diagnostic pop
|
||||||
}
|
#endif // __GNUC__
|
||||||
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
@@ -952,7 +1013,6 @@ inline const ListValue* ListValue::internal_default_instance() {
|
|||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
#ifndef SWIG
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
@@ -964,7 +1024,6 @@ inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::NullValue>()
|
|||||||
|
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
// @@protoc_insertion_point(global_scope)
|
||||||
|
|
||||||
|
|||||||
+30
-39
@@ -63,28 +63,22 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
#if defined(GOOGLE_PROTOBUF_ARCH_POWER)
|
#ifdef GOOGLE_PROTOBUF_ARCH_32_BIT
|
||||||
#if defined(_LP64) || defined(__LP64__)
|
typedef intptr_t Atomic32;
|
||||||
typedef int32 Atomic32;
|
typedef int64 Atomic64;
|
||||||
typedef intptr_t Atomic64;
|
|
||||||
#else
|
#else
|
||||||
typedef intptr_t Atomic32;
|
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
|
||||||
typedef int64 Atomic64;
|
// means Atomic64 and AtomicWord should be the same type on 64-bit.
|
||||||
#endif
|
#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL)
|
||||||
#else
|
// NaCl's intptr_t is not actually 64-bits on 64-bit!
|
||||||
typedef int32 Atomic32;
|
// http://code.google.com/p/nativeclient/issues/detail?id=1162
|
||||||
#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
|
// sparcv9's pointer type is 32bits
|
||||||
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
|
typedef intptr_t Atomic32;
|
||||||
// means Atomic64 and AtomicWord should be the same type on 64-bit.
|
typedef int64 Atomic64;
|
||||||
#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL)
|
#else
|
||||||
// NaCl's intptr_t is not actually 64-bits on 64-bit!
|
typedef int32 Atomic32;
|
||||||
// http://code.google.com/p/nativeclient/issues/detail?id=1162
|
typedef intptr_t Atomic64;
|
||||||
// sparcv9's pointer type is 32bits
|
#endif
|
||||||
typedef int64 Atomic64;
|
|
||||||
#else
|
|
||||||
typedef intptr_t Atomic64;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
|
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
|
||||||
@@ -123,8 +117,8 @@ Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
// ensure that no later memory access can be reordered ahead of the operation.
|
// ensure that no later memory access can be reordered ahead of the operation.
|
||||||
// "Release" operations ensure that no previous memory access can be reordered
|
// "Release" operations ensure that no previous memory access can be reordered
|
||||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
|
||||||
// access.
|
// memory access.
|
||||||
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value);
|
Atomic32 new_value);
|
||||||
@@ -132,10 +126,10 @@ Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value);
|
Atomic32 new_value);
|
||||||
|
|
||||||
#if defined(__MINGW32__) && defined(MemoryBarrier)
|
// This function was renamed from MemoryBarrier to MemoryBarrierInternal
|
||||||
#undef MemoryBarrier
|
// because MemoryBarrier is a define in Windows ARM builds and we do not
|
||||||
#endif
|
// undefine it because we call it from this function.
|
||||||
void MemoryBarrier();
|
void MemoryBarrierInternal();
|
||||||
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
|
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
|
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
|
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
@@ -180,7 +174,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
|
|||||||
#include <google/protobuf/stubs/atomicops_internals_tsan.h>
|
#include <google/protobuf/stubs/atomicops_internals_tsan.h>
|
||||||
// MSVC.
|
// MSVC.
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
|
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) || defined(GOOGLE_PROTOBUF_ARCH_ARM)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_x86_msvc.h>
|
#include <google/protobuf/stubs/atomicops_internals_x86_msvc.h>
|
||||||
#else
|
#else
|
||||||
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||||
@@ -194,16 +188,16 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
|
|||||||
#elif defined(GOOGLE_PROTOBUF_OS_AIX)
|
#elif defined(GOOGLE_PROTOBUF_OS_AIX)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_power.h>
|
#include <google/protobuf/stubs/atomicops_internals_power.h>
|
||||||
|
|
||||||
// Apple.
|
|
||||||
#elif defined(GOOGLE_PROTOBUF_OS_APPLE)
|
|
||||||
#include <google/protobuf/stubs/atomicops_internals_macosx.h>
|
|
||||||
|
|
||||||
// GCC.
|
// GCC.
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
|
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
|
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
|
||||||
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM) && defined(__linux__)
|
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM) && defined(__linux__)
|
||||||
|
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
|
||||||
|
#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>
|
||||||
|
#else
|
||||||
#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>
|
#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>
|
||||||
|
#endif
|
||||||
#elif defined(GOOGLE_PROTOBUF_ARCH_AARCH64)
|
#elif defined(GOOGLE_PROTOBUF_ARCH_AARCH64)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_arm64_gcc.h>
|
#include <google/protobuf/stubs/atomicops_internals_arm64_gcc.h>
|
||||||
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
|
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
|
||||||
@@ -213,7 +207,10 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
|
|||||||
#elif defined(GOOGLE_PROTOBUF_ARCH_POWER)
|
#elif defined(GOOGLE_PROTOBUF_ARCH_POWER)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_power.h>
|
#include <google/protobuf/stubs/atomicops_internals_power.h>
|
||||||
#elif defined(__native_client__)
|
#elif defined(__native_client__)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_pnacl.h>
|
// The static_asserts in the C++11 atomics implementation cause it to fail
|
||||||
|
// with certain compilers, e.g. nvcc on macOS. Don't use elsewhere unless
|
||||||
|
// the TODO in that file is addressed.
|
||||||
|
#include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h>
|
||||||
#elif defined(GOOGLE_PROTOBUF_ARCH_PPC)
|
#elif defined(GOOGLE_PROTOBUF_ARCH_PPC)
|
||||||
#include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h>
|
#include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h>
|
||||||
#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
|
#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
|
||||||
@@ -233,12 +230,6 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
|
|||||||
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// On some platforms we need additional declarations to make AtomicWord
|
|
||||||
// compatible with our other Atomic* types.
|
|
||||||
#if defined(GOOGLE_PROTOBUF_OS_APPLE)
|
|
||||||
#include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR
|
||||||
|
|
||||||
#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
|
||||||
|
|||||||
+13
-13
@@ -37,7 +37,7 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT
|
__asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,9 +117,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
Atomic32 increment) {
|
Atomic32 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
|
Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
@@ -148,7 +148,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
@@ -178,7 +178,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,9 +253,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
Atomic64 increment) {
|
Atomic64 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment);
|
Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
@@ -284,7 +284,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
@@ -314,7 +314,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,17 +115,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
pLinuxKernelMemoryBarrier();
|
pLinuxKernelMemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,12 +135,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
Atomic32 value = *ptr;
|
Atomic32 value = *ptr;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,17 +110,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,12 +130,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
Atomic32 value = *ptr;
|
Atomic32 value = *ptr;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-122
@@ -1,122 +0,0 @@
|
|||||||
// Protocol Buffers - Google's data interchange format
|
|
||||||
// Copyright 2012 Google Inc. All rights reserved.
|
|
||||||
// https://developers.google.com/protocol-buffers/
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
|
||||||
|
|
||||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
|
||||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
|
||||||
|
|
||||||
// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
|
|
||||||
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
|
|
||||||
// on others, it's a long. When AtomicWord and Atomic32 are based on different
|
|
||||||
// fundamental types, their pointers are incompatible.
|
|
||||||
//
|
|
||||||
// This file defines function overloads to allow both AtomicWord and Atomic32
|
|
||||||
// data to be used with this interface.
|
|
||||||
//
|
|
||||||
// On LP64 platforms, AtomicWord and Atomic64 are both always long,
|
|
||||||
// so this problem doesn't occur.
|
|
||||||
|
|
||||||
#if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
|
|
||||||
|
|
||||||
namespace google {
|
|
||||||
namespace protobuf {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return NoBarrier_AtomicExchange(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord increment) {
|
|
||||||
return NoBarrier_AtomicIncrement(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord increment) {
|
|
||||||
return Barrier_AtomicIncrement(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return Acquire_CompareAndSwap(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return Release_CompareAndSwap(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
|
|
||||||
NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
|
||||||
return Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
|
||||||
return Release_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {
|
|
||||||
return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
|
|
||||||
return Acquire_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
|
|
||||||
return Release_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace protobuf
|
|
||||||
} // namespace google
|
|
||||||
|
|
||||||
#endif // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
|
|
||||||
|
|
||||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
|
|
||||||
+8
-8
@@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
// This file is an internal atomic implementation, use atomicops.h instead.
|
||||||
|
|
||||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_C11_ATOMIC_H_
|
||||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_C11_ATOMIC_H_
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ typedef volatile std::atomic<Atomic32>* AtomicLocation32;
|
|||||||
static_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32),
|
static_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32),
|
||||||
"incompatible 32-bit atomic layout");
|
"incompatible 32-bit atomic layout");
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
#if defined(__GLIBCXX__)
|
#if defined(__GLIBCXX__)
|
||||||
// Work around libstdc++ bug 51038 where atomic_thread_fence was declared but
|
// Work around libstdc++ bug 51038 where atomic_thread_fence was declared but
|
||||||
// not defined, leading to the linker complaining about undefined references.
|
// not defined, leading to the linker complaining about undefined references.
|
||||||
@@ -119,7 +119,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed);
|
((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
@@ -135,7 +135,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed);
|
return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed);
|
((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
@@ -218,7 +218,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed);
|
return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,4 +228,4 @@ inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
|||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
|
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_C11_ATOMIC_H_
|
||||||
+6
-6
@@ -38,7 +38,7 @@ namespace internal {
|
|||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
|
||||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||||
return old_value;
|
return old_value;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
|
||||||
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
||||||
return old_value;
|
return old_value;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
|
||||||
__ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
|
__ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
|
||||||
return old_value;
|
return old_value;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
__atomic_store_n(ptr, value, __ATOMIC_RELAXED);
|
__atomic_store_n(ptr, value, __ATOMIC_RELAXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
|
||||||
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
|
||||||
return old_value;
|
return old_value;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|||||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
__atomic_compare_exchange_n(ptr, &old_value, new_value, true,
|
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
|
||||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||||
return old_value;
|
return old_value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,225 +0,0 @@
|
|||||||
// Protocol Buffers - Google's data interchange format
|
|
||||||
// Copyright 2012 Google Inc. All rights reserved.
|
|
||||||
// https://developers.google.com/protocol-buffers/
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// This file is an internal atomic implementation, use atomicops.h instead.
|
|
||||||
|
|
||||||
#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
|
||||||
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
|
||||||
|
|
||||||
#include <libkern/OSAtomic.h>
|
|
||||||
|
|
||||||
namespace google {
|
|
||||||
namespace protobuf {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap32(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 old_value;
|
|
||||||
do {
|
|
||||||
old_value = *ptr;
|
|
||||||
} while (!OSAtomicCompareAndSwap32(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr)));
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
|
||||||
OSMemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|
||||||
Atomic32 value = *ptr;
|
|
||||||
MemoryBarrier();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
|
|
||||||
// 64-bit implementation on 64-bit platform
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap64(old_value, new_value,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 old_value;
|
|
||||||
do {
|
|
||||||
old_value = *ptr;
|
|
||||||
} while (!OSAtomicCompareAndSwap64(old_value, new_value,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr)));
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return OSAtomicAdd64Barrier(increment,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap64Barrier(
|
|
||||||
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
// The lib kern interface does not distinguish between
|
|
||||||
// Acquire and Release memory barriers; they are equivalent.
|
|
||||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|
||||||
Atomic64 value = *ptr;
|
|
||||||
MemoryBarrier();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(__LP64__)
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace protobuf
|
|
||||||
} // namespace google
|
|
||||||
|
|
||||||
#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
|
|
||||||
+17
-17
@@ -125,8 +125,8 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
// ensure that no later memory access can be reordered ahead of the operation.
|
// ensure that no later memory access can be reordered ahead of the operation.
|
||||||
// "Release" operations ensure that no previous memory access can be reordered
|
// "Release" operations ensure that no previous memory access can be reordered
|
||||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
|
||||||
// access.
|
// memory access.
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
@@ -149,17 +149,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__asm__ __volatile__("sync" : : : "memory");
|
__asm__ __volatile__("sync" : : : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,12 +169,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
Atomic32 value = *ptr;
|
Atomic32 value = *ptr;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,9 +247,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
Atomic64 increment) {
|
Atomic64 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment);
|
Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,20 +257,20 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
|||||||
// ensure that no later memory access can be reordered ahead of the operation.
|
// ensure that no later memory access can be reordered ahead of the operation.
|
||||||
// "Release" operations ensure that no previous memory access can be reordered
|
// "Release" operations ensure that no previous memory access can be reordered
|
||||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
|
||||||
// access.
|
// memory access.
|
||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,11 +280,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,12 +294,12 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
|||||||
|
|
||||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||||
Atomic64 value = *ptr;
|
Atomic64 value = *ptr;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier(void) {
|
inline void MemoryBarrierInternal(void) {
|
||||||
asm volatile (
|
asm volatile (
|
||||||
" lwsync \n\t"
|
" lwsync \n\t"
|
||||||
" isync \n\t"
|
" isync \n\t"
|
||||||
|
|||||||
@@ -97,22 +97,22 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr,
|
|||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr,
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr,
|
||||||
Atomic32 increment) {
|
Atomic32 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);
|
Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr,
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr,
|
||||||
Atomic32 old_value, Atomic32 new_value) {
|
Atomic32 old_value, Atomic32 new_value) {
|
||||||
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr,
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr,
|
||||||
Atomic32 old_value, Atomic32 new_value) {
|
Atomic32 old_value, Atomic32 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -121,15 +121,15 @@ inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) {
|
|||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() { __asm__ __volatile__("sync" : : : "memory"); }
|
inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); }
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) {
|
inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,12 +137,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; }
|
|||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) {
|
inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) {
|
||||||
Atomic32 value = *ptr;
|
Atomic32 value = *ptr;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32 *ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32 *ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,16 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|||||||
return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment);
|
return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier(void) {
|
inline void MemoryBarrierInternal(void) {
|
||||||
membar_producer();
|
membar_producer();
|
||||||
membar_consumer();
|
membar_consumer();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
Atomic32 increment) {
|
Atomic32 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment);
|
Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
Atomic32 old_value,
|
Atomic32 old_value,
|
||||||
Atomic32 new_value) {
|
Atomic32 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,9 +129,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 incre
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment);
|
Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,14 +139,14 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
Atomic64 old_value,
|
Atomic64 old_value,
|
||||||
Atomic64 new_value) {
|
Atomic64 new_value) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64 *ptr,
|
|||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);
|
__tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,18 +119,18 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|||||||
|
|
||||||
// 64-bit implementations of memory barrier can be simpler, because it
|
// 64-bit implementations of memory barrier can be simpler, because it
|
||||||
// "mfence" is guaranteed to exist.
|
// "mfence" is guaranteed to exist.
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
__asm__ __volatile__("mfence" : : : "memory");
|
__asm__ __volatile__("mfence" : : : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
|
if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
|
||||||
__asm__ __volatile__("mfence" : : : "memory");
|
__asm__ __volatile__("mfence" : : : "memory");
|
||||||
} else { // mfence is faster but not present on PIII
|
} else { // mfence is faster but not present on PIII
|
||||||
@@ -168,7 +168,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
@@ -262,7 +262,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -44,9 +44,10 @@ namespace google {
|
|||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
inline void MemoryBarrierInternal() {
|
||||||
// We use MemoryBarrier from WinNT.h
|
// On ARM this is a define while on x86/x64 this is
|
||||||
::MemoryBarrier();
|
// a function declared in WinNT.h
|
||||||
|
MemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
MemoryBarrier();
|
MemoryBarrierInternal();
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user